/// <summary> /// The main entry point for the application. /// </summary> static void Main(String[] args) { if (Environment.UserInteractive) { if (args != null && args.Length == 1 && args[0].StartsWith("-i", StringComparison.OrdinalIgnoreCase)) { TcmCDService.Configuration.Installer.Install(Assembly.GetExecutingAssembly().Location); return; } if (args != null && args.Length == 1 && args[0].StartsWith("-u", StringComparison.OrdinalIgnoreCase)) { TcmCDService.Configuration.Installer.Uninstall(Assembly.GetExecutingAssembly().Location); return; } Console.WriteLine("[i] Starting TcmCacheService"); Logger.Info("TcmCacheService starting..."); using (ZeroMQBroker cache = new ZeroMQBroker(new TcmCDService.Configuration.Settings(Config.Instance.Settings))) { cache.Connect(); Console.WriteLine("[i] Press any key to exit."); Console.ReadKey(); Logger.Info("TcmCacheService stopping..."); } Console.WriteLine("[i] Stopping TcmCacheService"); } else { ServiceBase.Run(new WindowsService()); } }
/// <summary> /// When implemented in a derived class, executes when a Start command is sent to the service by the Service Control Manager (SCM) or when the operating system starts (for a service that starts automatically). Specifies actions to take when the service starts. /// </summary> /// <param name="args">Data passed by the start command.</param> protected override void OnStart(String[] args) { Logger.Info("TcmCacheService starting..."); mZeroMQBroker.Connect(); }