Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11364


Ignore:
Timestamp:
09/15/14 10:35:38 (10 years ago)
Author:
ascheibe
Message:

#2244 added new installer for the HeuristicLab Hive Slave

Location:
trunk/sources
Files:
2 added
2 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.Slave.WindowsService/3.3/Program.cs

    r11171 r11364  
    2020#endregion
    2121
     22using System;
     23using System.Configuration.Install;
     24using System.Reflection;
    2225using System.ServiceProcess;
    2326
    2427namespace HeuristicLab.Clients.Hive.SlaveCore.WindowsService {
    2528  static class Program {
    26     /// <summary>
    27     /// The main entry point for the application.
    28     /// </summary>
    29     static void Main() {
    30       ServiceBase[] ServicesToRun;
    31       ServicesToRun = new ServiceBase[] 
    32       {
    33         new SlaveWindowsService()
    34       };
    35       ServiceBase.Run(ServicesToRun);
     29    private static void Main(string[] args) {
     30      // Install as service, see http://stackoverflow.com/a/12703878
     31      if (Environment.UserInteractive) {
     32        try {
     33          string parameter = string.Concat(args);
     34          switch (parameter) {
     35            case "--install":
     36              ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
     37              break;
     38            case "--uninstall":
     39              ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
     40              break;
     41          }
     42        }
     43        catch (Exception ex) {
     44          Console.WriteLine("Error on (un)install of Hive Slave service: " + Environment.NewLine + ex);
     45        }
     46      } else {
     47        ServiceBase[] ServicesToRun;
     48        ServicesToRun = new ServiceBase[]
     49        {
     50          new SlaveWindowsService()
     51        };
     52        ServiceBase.Run(ServicesToRun);
     53      }
    3654    }
    3755  }
Note: See TracChangeset for help on using the changeset viewer.