public override void Connect(IReadOnlyCollection <Component> instanceComponents) { Logger.Instance.Log(LogLevel.Info, "\nConfiguring components ({0}, {1}, {2}, {3}) to work with component({4}):\n", ESAgentComponentId, ESIndexComponentId, ESZookeeperComponentId, ESFileProcessorComponentId, DatabaseComponentId); ESAgentComponent esAgent = instanceComponents.Single(c => c.Id == ESAgentComponentId) as ESAgentComponent; ESIndexComponent esIndex = instanceComponents.Single(c => c.Id == ESIndexComponentId) as ESIndexComponent; ESZooKeeperComponent esZooKeeper = instanceComponents.Single(c => c.Id == ESZookeeperComponentId) as ESZooKeeperComponent; ESFileProcessorComponent esFileProcessor = instanceComponents.Single(c => c.Id == ESFileProcessorComponentId) as ESFileProcessorComponent; DatabaseComponent databaseComponent = instanceComponents.Single(c => c.Id == DatabaseComponentId) as DatabaseComponent; DropSolrIndex(esIndex); string serviceNameXPath = "/configuration/ServiceName"; esFileProcessor.ServiceName = FileSystemFactory.GetFileSystem(esFileProcessor.ServerName).XmlHelper.XmlPeek(esFileProcessor.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esFileProcessor.ServerName, esFileProcessor.ServiceName); esAgent.ServiceName = FileSystemFactory.GetFileSystem(esAgent.ServerName).XmlHelper.XmlPeek(esAgent.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esAgent.ServerName, esAgent.ServiceName); esIndex.ServiceName = FileSystemFactory.GetFileSystem(esIndex.ServerName).XmlHelper.XmlPeek(esIndex.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esIndex.ServerName, esIndex.ServiceName); esZooKeeper.ServiceName = FileSystemFactory.GetFileSystem(esZooKeeper.ServerName).XmlHelper.XmlPeek(esZooKeeper.PathToConfig, serviceNameXPath); WindowsServiceHelper.StopService(esZooKeeper.ServerName, esZooKeeper.ServiceName); //Wait Until services are stopped for 30 seconds Thread.Sleep(30000); HttpServerConnection connection = IomFactory.CreateHttpServerConnection(databaseComponent.InnovatorUrl, databaseComponent.DatabaseName, databaseComponent.LoginOfRootInnovatorUser, databaseComponent.PasswordOfRootInnovatorUser.Value); try { connection.Login(); Innovator innovator = new Innovator(connection); EditVariable(innovator, "ES_SolrUrl", esIndex.ESAIClusterUrl); EditVariable(innovator, "ES_AIClusterUrl", esIndex.ESAIClusterUrl); EditCryptoPwd(innovator, esAgent); } finally { connection.Logout(); } UpdateESZooKeeperServiceConfig(esZooKeeper, databaseComponent); WindowsServiceHelper.StartService(esZooKeeper.ServerName, esZooKeeper.ServiceName); UpdateESIndexServiceConfig(esIndex, databaseComponent); WindowsServiceHelper.StartService(esIndex.ServerName, esIndex.ServiceName); UpdateESAgentServiceConfig(esAgent, databaseComponent); WindowsServiceHelper.StartService(esAgent.ServerName, esAgent.ServiceName); UpdateESFileProcessorServiceConfig(esFileProcessor, databaseComponent); WindowsServiceHelper.StartService(esFileProcessor.ServerName, esFileProcessor.ServiceName); ReloadSolrCollection(esIndex); }
private void ValidateServiceInBackground(object state) { var tcs = (TaskCompletionSource <ServiceControllerStatus?>)state; Thread.Sleep(1500); var status = WindowsServiceHelper.Validate(WindowsServiceHelper.UlteriusServiceName); tcs.SetResult(status); }
protected override void OnAfterInstall(System.Collections.IDictionary savedState) { // Set InteractiveState checkbox for BoltClient. WindowsServiceHelper.ChangeInteractiveState(Params.ServiceName, true); // Start "BoltClient". //ServiceController scBC = new ServiceController(Params.ServiceName); //scBC.Start(); }
private void ToggleServiceStateInBackground(object state) { var tcs = (TaskCompletionSource <bool>)state; Thread.Sleep(1500); var result = IsServiceRunning ? WindowsServiceHelper.Stop(WindowsServiceHelper.UlteriusServiceName) : WindowsServiceHelper.Start(WindowsServiceHelper.UlteriusServiceName); tcs.SetResult(result); }
public WindowsServicesControl() { _model = new WindowsServicesModel(); _windowsServiceHelper = new WindowsServiceHelper(); DataContext = _model; if (!DesignerProperties.GetIsInDesignMode(this)) { SetRuntimeOptions(); } }
protected override void OnBeforeUninstall(IDictionary savedState) { Trace.WriteLine("ERMT: ServiceStartAndStop OnBeforeUninstall"); try { WindowsServiceHelper.StopService(Context.Parameters["ServiceName"]); } catch (Exception ex) { Context.LogMessage("The service couldn't be stopped. Please stop it manually and run the uninstall program again. Exception message: " + ex.Message); } base.OnBeforeUninstall(savedState); }
protected override void OnAfterInstall(IDictionary savedState) { Trace.WriteLine("ERMT: ServiceStartAndStop OnAfterInstall"); try { WindowsServiceHelper.StartService(Context.Parameters["ServiceName"]); } catch (Exception ex) { Context.LogMessage("The service couldn't be started. Please start it manually from the services console. Exception message: " + ex.Message); } base.OnAfterInstall(savedState); }
public WindowsServicesControl() { Wu10Logger.LogInfo("Windows Services initializing."); _model = new WindowsServicesModel(); _windowsServiceHelper = new WindowsServiceHelper(); DataContext = _model; if (!DesignerProperties.GetIsInDesignMode(this)) { SetRuntimeOptions(); } Wu10Logger.LogInfo("Windows Services initialized."); }
public static void SetApplicationPaths(ApplicationPaths paths, IReadOnlyCollection <string> commandLineArgs) { string?currentDomainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory; if (WindowsServiceHelper.IsRunningAsService(commandLineArgs)) { TempLogger.WriteLine( $"Switching current directory from {Directory.GetCurrentDirectory()} to {currentDomainBaseDirectory}"); Directory.SetCurrentDirectory(currentDomainBaseDirectory); } paths.BasePath ??= currentDomainBaseDirectory; paths.ContentBasePath ??= Directory.GetCurrentDirectory(); }
static void Main(string[] args) { try { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); var timerServices = new WindowsServiceItemCollection(); RegisterSendSmsService(timerServices); RegisterSynDateService(timerServices); WindowsServiceHelper.RunServices(timerServices, WindowsServiceTimerExceptionCallBack); } catch (Exception ex) { WriterLog(ex.ToString(), "error"); } }