public bool Start(HostControl hostControl) { _log.InfoFormat("Starting RapidTransit Host"); var started = new List <ServiceControl>(); try { var scanner = new AssemblyScanner(); List <AssemblyRegistration> registrations = scanner.GetAssemblyRegistrations().ToList(); _log.Info($"Found {registrations.Count} assembly registrations"); foreach (var registration in registrations) { _log.Info($"Assembly: {registration.Assembly.GetName().Name}"); foreach (var type in registration.Types) { _log.Info($" Type: {type.GetTypeName()}"); } } var busFactoryType = scanner.GetHostBusFactoryType(); if (busFactoryType == null) { throw new ConfigurationException("A valid transport assembly was not found."); } _bootstrapperScope = CreateBootstrapperScope(registrations, busFactoryType); var bootstrappers = _bootstrapperScope.Resolve <IEnumerable <IServiceBootstrapper> >(); List <ServiceControl> services = bootstrappers.Select(x => x.CreateService()).ToList(); foreach (ServiceControl serviceControl in services) { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StartService(hostControl, serviceControl); started.Add(serviceControl); } _services = started; return(true); } catch (Exception ex) { _log.Error("Service failed to start", ex); Parallel.ForEach(started, service => { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StopService(hostControl, service); }); throw; } }
public bool Start(HostControl hostControl) { _log.InfoFormat("Starting Subscriber Activity Service"); var started = new List<ServiceControl>(); try { _services = _serviceBootstrappers.Select(x => x.CreateService()).ToList(); _log.InfoFormat("Starting {0} services", _services.Count()); foreach (ServiceControl activityService in _services) { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StartService(hostControl, activityService); started.Add(activityService); } return true; } catch (Exception ex) { _log.Error("Service failed to start", ex); Parallel.ForEach(started, service => { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StopService(hostControl, service); }); throw; } }
public bool Start(HostControl hostControl) { _log.InfoFormat("Starting Subscriber Activity Service"); var started = new List <ServiceControl>(); try { _services = _serviceBootstrappers.Select(x => x.CreateService()).ToList(); _log.InfoFormat("Starting {0} services", _services.Count()); foreach (ServiceControl activityService in _services) { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StartService(hostControl, activityService); started.Add(activityService); } return(true); } catch (Exception ex) { _log.Error("Service failed to start", ex); Parallel.ForEach(started, service => { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StopService(hostControl, service); }); throw; } }
public bool Start(HostControl hostControl) { _log = HostLogger.Get <SampleService>(); _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); Thread.Sleep(1000); ThreadPool.QueueUserWorkItem(x => { Thread.Sleep(3000); _log.Info("Requesting a restart!!!"); hostControl.Restart(); // _log.Info("Dying an ungraceful death"); // // throw new InvalidOperationException("Oh, what a world."); }); _log.Info("SampleService Started"); return(true); }
public bool Start(HostControl hostControl) { _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); Thread.Sleep(1000); if(_throwOnStart) { _log.Info("Throwing as requested"); throw new InvalidOperationException("Throw on Start Requested"); } ThreadPool.QueueUserWorkItem(x => { Thread.Sleep(3000); if(_throwUnhandled) throw new InvalidOperationException("Throw Unhandled In Random Thread"); _log.Info("Requesting stop"); hostControl.Stop(); }); _log.Info("SampleService Started"); return true; }
public bool Start(HostControl hostControl) { _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); Thread.Sleep(1000); if (_throwOnStart) { _log.Info("Throwing as requested"); throw new InvalidOperationException("Throw on Start Requested"); } ThreadPool.QueueUserWorkItem(x => { Thread.Sleep(3000); if (_throwUnhandled) { throw new InvalidOperationException("Throw Unhandled In Random Thread"); } _log.Info("Requesting stop"); hostControl.Stop(); }); _log.Info("SampleService Started"); return(true); }
public bool Start(HostControl hostControl) { _log = HostLogger.Get <AkkaService>(); _log.Info("Service Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); Thread.Sleep(1000); /* * ThreadPool.QueueUserWorkItem(x => * { * * Thread.Sleep(3000); * _log.Info("Requesting a restart!!!"); * hostControl.Restart(); * _log.Info("Dying an ungraceful death"); * throw new InvalidOperationException("Oh, what a world."); * }); */ _log.Info("AkkaService Started"); _pipeline = new ProcessPipeline(); // Lets subscribe to Data-Stream return(true); }
public bool Start(HostControl hostControl) { _logger.Info("Starting service"); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(60)); try { // MassTransit的设置和启动 // 启动后会监听RabbitMQ中注册的Queue // 然后Consumer会接受消息 _logger.Info("Start MassTransit"); _busControl = ConfigureMassTransit(); _busControl.Start(); // 调用Handle var animal = _kernel.Get <ISampleHandle>().Handle(1).Result; _logger.Info($"AnimalKey:{animal.AnimalKey}, Sex:{animal.Sex}, Species:{animal.Species}"); _logger.Info("Service started"); return(true); } catch (Exception ex) { _logger.Fatal(ex, "Error starting service"); return(false); } }
public bool Start(HostControl hostControl) { _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); _server.OpenAsync(); var setting = JsonOperater.GetAppSetting(); _timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); _timer.Interval = 1000 * 60 * setting.Period; _timer.Enabled = true; _timer.Start(); //var setting = JsonOperater.GetAppSetting(); //FileManager.InitStates(setting); //foreach (var key in setting.Directory.Keys) //{ // if (FileShare.ConnectState(setting.Directory[key], setting.UserName, setting.PassWord)) // { // var needAnalyzes = FileManager.GetNeedAnalyzeFiles(setting.Directory[key], key); // Analyzer.AnalyzeRecord(needAnalyzes, setting, key); // } //} _log.Info("SampleService Started"); return(true); }
public bool Start(HostControl hostControl) { hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(60)); if (this.UseWebRepository) { Console.WriteLine("Launching WebRepository..."); var options = new StartOptions(); options.Urls.Add("http://+:80/"); this.WebRepositoryApp = WebApp.Start <Ticketmaster.Dsc.WebRepository.OwinStartup>(options); } if (this.UseDscManagerApi || this.UseJobServer) { var dscOptions = Ticketmaster.Dsc.DscManager.OwinStartup.GetDscManagerOptions(); dscOptions.UseApi = this.UseDscManagerApi; dscOptions.UseHangfireJobServer = this.UseJobServer; var options = new StartOptions(); options.Urls.Add("https://+:443"); this.DscManagerApp = WebApp.Start <Ticketmaster.Dsc.DscManager.OwinStartup>(options); } Console.WriteLine("Finished loading application. Press any key to exit."); return(true); }
public bool Start(HostControl hostControl) { _log = HostLogger.Get<SampleService>(); _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); Thread.Sleep(1000); ThreadPool.QueueUserWorkItem(x => { // Thread.Sleep(3000); // _log.Info("Requesting a restart!!!"); // hostControl.Restart(); // _log.Info("Dying an ungraceful death"); // // throw new InvalidOperationException("Oh, what a world."); }); _log.Info("SampleService Started"); return true; }
public bool Start(HostControl hostControl) { _log.InfoFormat($"Starting {GetType().GetDisplayName()}"); var started = new List<ServiceControl>(); try { var scanner = new ServiceAssemblyScanner(); List<AssemblyRegistration> registrations = scanner.GetAssemblyRegistrations().ToList(); _log.Info($"Found {registrations.Count} assembly registrations"); foreach (var registration in registrations) { _log.Info($"Assembly: {registration.Assembly.GetName().Name}"); foreach (var type in registration.Types) _log.Info($" Type: {type.GetTypeName()}"); } var busFactoryType = scanner.GetHostBusFactoryType(); if (busFactoryType == null) throw new ConfigurationException("A valid transport assembly was not found."); _bootstrapperScope = CreateBootstrapperScope(registrations, busFactoryType); var bootstrappers = _bootstrapperScope.Resolve<IEnumerable<IServiceBootstrapper>>(); List<ServiceControl> services = bootstrappers.Select(x => x.CreateService()).ToList(); Parallel.ForEach(services, serviceControl => { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StartService(hostControl, serviceControl); lock (started) { started.Add(serviceControl); } }); _services.AddRange(started); return true; } catch (Exception ex) { _log.Error("Service failed to start", ex); Parallel.ForEach(started, service => { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StopService(hostControl, service); }); throw; } }
public bool Stop(HostControl hostControl) { hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(60)); if (LabServiceStopped != null) { LabServiceStopped(this, new LabServiceEventArgs("Lab Stopped")); } return(true); }
void HostControl.RequestAdditionalTime(TimeSpan timeRemaining) { if (_hostControl == null) { throw new InvalidOperationException("The HostControl reference has not been set, this is invalid"); } _hostControl.RequestAdditionalTime(timeRemaining); }
public bool Start(HostControl hostControl) { hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); _container = createContainer(); _monitor = _container.With(_settings).GetInstance <CaseMonitor>(); _monitor.Start(); return(true); }
public bool Start(HostControl hostControl) { hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(30)); WatchCmdFile(); if (LabServiceStarted != null) { LabServiceStarted(this, new LabServiceEventArgs("Lab Starting")); } timer.Enabled = true; return(true); }
/// <summary> /// The Start /// </summary> /// <param name="hostControl">The hostControl<see cref="HostControl"/></param> /// <returns>The <see cref="bool"/></returns> public bool Start(HostControl hostControl) { hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(5)); _timer.Elapsed += (s, e) => { _timer.Stop(); _logger.LogInformation("Timer Stoped at {SignalTime}", e.SignalTime); _timer.Start(); }; return(true); }
public bool Stop(HostControl hostControl) { _log.InfoFormat("Stopping {0} services", _services.Count()); if (_services != null) { Parallel.ForEach(_services, service => { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StopService(hostControl, service); }); } return true; }
public bool Stop(HostControl hostControl) { //_log.InfoFormat("Stopping {0} services", _services.Count); if (_services != null) { Parallel.ForEach(_services, service => { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); StopService(hostControl, service); }); } return(true); }
public bool Stop(HostControl hostControl) { _scheduler.Shutdown(true); _cancellationTokenSource.Cancel(); TimeSpan timeout = TimeSpan.FromSeconds(30); while (!_task.Wait(timeout)) { hostControl.RequestAdditionalTime(timeout); } //TODO: maybe jobs have resources to dispose? return(true); }
/// <summary> /// Creates an instance of the TabMonAgent and starts it. /// </summary> /// <param name="hostControl">Service HostControl object</param> /// <returns>Indicator that service succesfully started</returns> public bool Start(HostControl hostControl) { // Request additional time from the service host due to how much initialization has to take place. hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); // Initialize and start service. try { agent = new TabMonAgent(); } catch (Exception) { return(false); } agent.Start(); return(agent.IsRunning()); }
/// <summary> /// Creates an instance of the TabMonAgent and starts it. /// </summary> /// <param name="hostControl">Service HostControl object</param> /// <returns>Indicator that service succesfully started</returns> public bool Start(HostControl hostControl) { // Request additional time from the service host due to how much initialization has to take place. hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); // Initialize and start service. try { agent = new TabMonAgent(); } catch (Exception) { return false; } agent.Start(); return agent.IsRunning(); }
public bool Start(HostControl hostControl) { _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); Thread.Sleep(1000); ThreadPool.QueueUserWorkItem(x => { Thread.Sleep(3000); _log.Info("Requesting stop"); hostControl.Stop(); }); _log.Info("SampleService Started"); return(true); }
public bool Start(HostControl hostControl) { _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); Thread.Sleep(1000); ThreadPool.QueueUserWorkItem(x => { Thread.Sleep(3000); _log.Info("Requesting stop"); hostControl.Stop(); }); _log.Info("SampleService Started"); return true; }
public void ApplicationWatchdogMonitor() { while (WatchdogThread.IsAlive) { string appName = serverInfo.ServerExeName.Value.Substring(0, serverInfo.ServerExeName.Value.Length - 4); if (!MonitoredAppExists(appName) && CurrentServerStatus == ServerStatus.Starting) { hostController.RequestAdditionalTime(TimeSpan.FromSeconds(30)); StartControl(hostController); InstanceProvider.GetServiceLogger().AppendLine($"Recieved start signal for server {serverInfo.ServerName}."); } while (MonitoredAppExists(appName) && CurrentServerStatus == ServerStatus.Started) { Thread.Sleep(5000); } if (MonitoredAppExists(appName) && CurrentServerStatus == ServerStatus.Stopping) { InstanceProvider.GetServiceLogger().AppendLine($"BedrockService signaled stop to application {appName}."); InstanceProvider.GetServiceLogger().AppendLine("Stopping..."); StopControl(); while (CurrentServerStatus == ServerStatus.Stopping) { Thread.Sleep(250); } } if (!MonitoredAppExists(appName) && CurrentServerStatus == ServerStatus.Started) { StopControl(); InstanceProvider.GetServiceLogger().AppendLine($"Started application {appName} was not found in running processes... Resarting {appName}."); StartControl(hostController); } if (!MonitoredAppExists(appName) && CurrentServerStatus == ServerStatus.Stopped) { InstanceProvider.GetServiceLogger().AppendLine("Server stopped successfully."); } while (!MonitoredAppExists(appName) && CurrentServerStatus == ServerStatus.Stopped) { Thread.Sleep(1000); } } }
public bool Start(HostControl hostControl) { _hostControl = hostControl; try { ValidSettingsCheck(); foreach (var brs in bedrockServers.OrderByDescending(t => t.serverInfo.Primary).ToList()) { _hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(30)); brs.CurrentServerStatus = BedrockServer.ServerStatus.Starting; brs.StartWatchdog(hostControl); Thread.Sleep(2000); } return true; } catch (Exception e) { InstanceProvider.GetServiceLogger().AppendLine($"Error Starting BedrockServiceWrapper {e.StackTrace}"); return false; } }
public bool Start(HostControl hostControl) { _hostControl = hostControl; try { ValidSettingsCheck(); foreach (var brs in bedrockServers.OrderByDescending(t => t.ServerConfig.Primary).ToList()) { _hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(30)); brs.Stopping = false; brs.StartControl(hostControl); Thread.Sleep(2000); } return(true); } catch (Exception e) { _log.Fatal("Error Starting BedrockServiceWrapper", e); return(false); } }
public bool Start(HostControl hostControl) { //Log Logger.Info("*************************************"); Logger.Info("********[Starting Service]***********"); Logger.Info("*************************************"); hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); //Initalize Service Workers var settings = new Settings(); // Start OWIN host _webApp = Microsoft.Owin.Hosting.WebApp.Start <WebAppConfig>(url: settings.GetServiceUrl()); Logger.Info("*************************************"); Logger.Info("********[Service Started]***********"); Logger.Info("*************************************"); return(true); }
public bool Start(HostControl hostControl) { _logger.Info("Starting service"); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(60)); try { _logger.Info("Start MassTransit"); _busControl = ConfigureMassTransit(); _busControl.Start(); _kernel.Get <Sample2Handler>().Handle(1).Wait(); //_logger.Info($"AnimalKey:{animal.AnimalKey}, Sex:{animal.Sex}, Species:{animal.Species}"); _logger.Info("Service started"); return(true); } catch (Exception ex) { _logger.Fatal(ex, "Error starting service"); return(false); } }
/// <summary> /// Stops the specified host control. /// </summary> /// <param name="hostControl">The host control.</param> /// <returns></returns> public override bool Stop(HostControl hostControl) { try { Logger.Information("Stopping Event Processor"); hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1)); _processorHost.UnregisterEventProcessorAsync().Wait(TimeSpan.FromMinutes(1)); } catch (Exception ex) { Logger.Warning(ex, "Error unregistering Event Processor"); } return base.Stop(hostControl); }
public bool Stop(HostControl hostControl) { hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(10)); return(true); }
public void RequestAdditionalTime(TimeSpan timeRemaining) { _hostControl.RequestAdditionalTime(timeRemaining); }
public bool Start(HostControl hostControl) { Logger.Info("Starting..."); foreach (var device in _settings.Devices) { foreach (var tuner in device.Tuners) { //var device = _settings.Devices[tuner.Device]; Logger.Info("Tuner: Name={0}, Enabled={3}, Device={1}, Port={2}", tuner.Name, device, tuner.ListenerPort, tuner.Enabled); if (tuner.Enabled) { var logger = LogManager.GetLogger(tuner.Name); var encoder = _settings.CaptureProfiles[tuner.Encoder]; //Create a LifetimeScope for this tuner var innerScope = _lifetimeScope.BeginLifetimeScope( "tuner", builder => { builder.RegisterInstance(logger); builder.RegisterInstance(tuner); builder.RegisterInstance(device); builder.RegisterInstance(encoder); builder.RegisterInstance(GetChannelProvider(device)).As <IChannelProvider>(); }); //Get a Processor from the innerScope var p = innerScope.Resolve <SageCommandProcessor>(); p.Initialize(); _processors.Add(p); var t = new TcpServer { Port = tuner.ListenerPort }; t.OnConnect += p.OnConnect; t.OnDataAvailable += p.OnDataAvailable; t.OnError += p.OnError; t.Open(); _servers.Add(t); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(5)); } } } if (_settings.EnableDiscovery) { Logger.Info("Starting Discovery Server on Port 8167"); _discoveryServer = new TcpServer { Port = 8167 }; _discoveryServer.OnConnect += DiscoveryServerOnConnect; _discoveryServer.OnDataAvailable += DiscoveryServerOnDataAvailable; _discoveryServer.Open(); } else { Logger.Info("Discovery Server not enabled."); } return(true); }
public bool Start(HostControl hostControl) { _log.Info("SampleService Starting..."); hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10)); _server.OpenAsync(); var setting = JsonOperater.GetAppSetting(); _timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); _timer.Interval = 1000 * 60 * setting.Period; _timer.Enabled = true; _timer.Start(); //var setting = JsonOperater.GetAppSetting(); //FileManager.InitStates(setting); //foreach (var key in setting.Directory.Keys) //{ // if (FileShare.ConnectState(setting.Directory[key], setting.UserName, setting.PassWord)) // { // var needAnalyzes = FileManager.GetNeedAnalyzeFiles(setting.Directory[key], key); // Analyzer.AnalyzeRecord(needAnalyzes, setting, key); // } //} _log.Info("SampleService Started"); return true; }