Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/29/12 09:57:15 (11 years ago)
Author:
abeham
Message:

#1985: Synchronized with trunk

Location:
branches/RuntimeOptimizer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/RuntimeOptimizer

  • branches/RuntimeOptimizer/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r7259 r8971  
    2222using System;
    2323using System.Diagnostics;
     24using System.IO;
     25using System.Reflection;
    2426using System.ServiceModel;
    2527using System.Threading;
    2628using System.Threading.Tasks;
    27 using HeuristicLab.Clients.Hive.SlaveCore.Properties;
    28 using HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts;
    2929using HeuristicLab.Common;
    3030using HeuristicLab.Core;
     
    5454
    5555    public Core() {
    56       var log = new ThreadSafeLog(Settings.Default.MaxLogCount);
     56      var log = new ThreadSafeLog(SlaveCore.Properties.Settings.Default.MaxLogCount);
    5757      this.pluginManager = new PluginManager(WcfService.Instance, log);
    5858      this.taskManager = new TaskManager(pluginManager, log);
     
    7676        slaveComm = new ServiceHost(typeof(SlaveCommunicationService));
    7777        slaveComm.Open();
    78        
     78
    7979        // delete all left over task directories
    8080        pluginManager.CleanPluginTemp();
     
    9696        }
    9797        ShutdownCore();
    98       } finally {
     98      }
     99      finally {
    99100        DeregisterServiceEvents();
    100101        waitShutdownSem.Release();
     
    185186            HeartbeatManager.Interval = TimeSpan.FromSeconds(interval);
    186187          }
     188          break;
     189        case MessageContainer.MessageType.ShutdownComputer:
     190          ShutdownComputer();
    187191          break;
    188192      }
     
    450454    }
    451455
     456    private void ShutdownComputer() {
     457      var t = TS.Task.Factory.StartNew(new Action(Shutdown));
     458      t.ContinueWith(c => {
     459        try {
     460          //we assume that *.exe means an executable in the current directory, otherwise it is a command
     461          if (SlaveCore.Properties.Settings.Default.ShutdownCommand.EndsWith(".exe")) {
     462            string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     463            Process.Start(Path.Combine(dirName, SlaveCore.Properties.Settings.Default.ShutdownCommand));
     464          } else {
     465            Process.Start(SlaveCore.Properties.Settings.Default.ShutdownCommand);
     466          }
     467        }
     468        catch (Exception ex) {
     469          if (ServiceEventLog != null) {
     470            EventLogManager.LogException(ex);
     471          } else
     472            throw ex;
     473        }
     474      });
     475    }
     476
    452477    /// <summary>
    453478    /// complete shutdown, should be called before the the application is exited
Note: See TracChangeset for help on using the changeset viewer.