/// <summary> /// Stops the service immediately, terminating any user activity. /// </summary> public void Stop() { lock (syncLock) { if (state == ServiceState.Stopped) { return; } SysLog.LogInformation("Config Service Stop"); SysLog.Flush(); base.Close(); state = ServiceState.Stopped; if (router != null) { handler.Stop(); handler = null; router.Stop(); router = null; } } }
private ServiceState state; // Current service state /// <summary> /// Constructor. /// </summary> public AppService() { this.router = null; this.handler = null; this.state = ServiceState.Stopped; // Prepare the service to accept remote ServiceControl commands. base.Open(); }
private LeafRouter CreateRouter() { const string settings = @" §ion LillTek.Datacenter.ConfigService SettingsFolder = {0} &endsection §ion MsgRouter AppName = Test AppDescription = Test Description RouterEP = physical://detached/test/leaf CloudEP = $(LillTek.DC.CloudEP) CloudAdapter = ANY UdpEP = ANY:0 TcpEP = ANY:0 TcpBacklog = 100 TcpDelay = off BkInterval = 1s MaxIdle = 5m EnableP2P = yes AdvertiseTime = 1m DefMsgTTL = 5 SharedKey = PLAINTEXT SessionCacheTime = 2m SessionRetries = 3 SessionTimeout = 10s MaxLogicalAdvertiseEPs = 256 DeadRouterTTL = 2s &endsection "; LeafRouter router; ConfigServiceHandler configHandler; string folder; folder = Path.GetTempPath() + "Settings"; Config.SetConfig(string.Format(settings, folder).Replace('&', '#')); MsgEP.ReloadAbstractMap(); router = new LeafRouter(); configHandler = new ConfigServiceHandler(); configHandler.Start(router, null, null, null); router.Start(); return(router); }
/// <summary> /// Starts the service, associating it with an <see cref="IServiceHost" /> instance. /// </summary> /// <param name="serviceHost">The service user interface.</param> /// <param name="args">Command line arguments.</param> public void Start(IServiceHost serviceHost, string[] args) { lock (syncLock) { if (router != null) { return; // Already started } // Global initialization NetTrace.Start(); Program.Config = new Config(ConfigServiceHandler.ConfigPrefix); Program.PerfCounters = null; // $todo(jeff.lill): new PerfCounterSet(true,Const.ConfigServicePerf,Const.ConfigServiceName); // Service initialization this.serviceHost = serviceHost; SysLog.LogInformation("Config Service v{0} Start", Helper.GetVersionString()); try { router = new LeafRouter(); router.Start(); handler = new ConfigServiceHandler(); handler.Start(router, null, null, null); state = ServiceState.Running; } catch (Exception e) { if (handler != null) { handler.Stop(); handler = null; } if (router != null) { router.Stop(); router = null; } SysLog.LogException(e); throw; } } }