private static void ConfigureService(HostConfiguration <SERVICE> config) { using (var sc = new ServiceController(config.Name)) { switch (config.Action) { case ActionEnum.Install: Install(config, sc); break; case ActionEnum.Uninstall: Uninstall(config, sc); break; case ActionEnum.Run: var testService = new InnerService(config.Name, () => Start(config), () => Stop(config)); var serviceHost = new Win32ServiceHost(testService); serviceHost.Run(); break; case ActionEnum.RunInteractive: Start(config); break; case ActionEnum.Stop: StopService(config, sc); break; case ActionEnum.Start: StartService(config, sc); break; } } }
public static void Run(string contentRootPath) { var baldrService = new BaldrService(contentRootPath); var serviceHost = new Win32ServiceHost(baldrService); serviceHost.Run(); }
private static void RunAsService(IServiceProvider services) { var schedulerService = new SchedulerService(services); var serviceHost = new Win32ServiceHost(schedulerService); serviceHost.Run(); }
public static void Main(string[] args) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); if (args.Length > 0 && args[0].Equals("Console")) { //数据迁移 // MyMigration.Migrate(); //启动报警上传检测 ForwardAlarmLogTask.Instance.Run(); //启动预案任务 PlanTaskScheduler.Instance.Start(); //启动查勤包生成线程 DutyCheckPackageRunner.Instance.Start(); Console.WriteLine("start Web host .."); var host = new WebHostBuilder().UseKestrel() .UseUrls("http://*:5001") .UseStartup <Startup>() .Build(); host.Start(); Console.WriteLine("Web host is runing.."); Console.ReadLine(); } else { var allInOneService = new AllInOneService(); var serviceHost = new Win32ServiceHost(allInOneService); serviceHost.Run(); } }
private static void RunAsService(string[] args) { var win32Service = new Win32Service(args.Where(a => a != RunAsServiceFlag).ToArray()); var serviceHost = new Win32ServiceHost(win32Service); serviceHost.Run(); }
protected override void InternalRun(string[] args) { if (args.Contains("/service-run", StringComparer.OrdinalIgnoreCase)) { Directory.SetCurrentDirectory(AppContext.BaseDirectory); Core.Log.LibDebug("Starting..."); Core.Log.InfoBasic("Current Directory: {0}", Directory.GetCurrentDirectory()); InitAction?.Invoke(); if (!string.IsNullOrWhiteSpace(BannerText)) { var bannerText = BannerText.Split("\r\n"); foreach (var line in bannerText) { Core.Log.InfoBasic(line); } } Core.Log.InfoBasic("*** RUNNING AS WINDOWS SERVICE ***"); ShowFullHeader(); try { var win32Service = new Win32Service(ServiceName, Service); var serviceHost = new Win32ServiceHost(win32Service); serviceHost.Run(); } catch (Exception ex) { Core.Log.Write(ex); } } else { base.InternalRun(args); } }
static void Main(string[] args) { var service = new WindowsService(); var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); }
public static void RunAsService(ISimpbot simpbot) { var simpbotService = new Win32SimpbotService(simpbot, "Simpbot.Cli.Service"); var serviceHost = new Win32ServiceHost(simpbotService); serviceHost.Run(); }
public static void Run(string serviceName, RavenConfiguration configuration) { var service = new RavenWin32Service(serviceName, configuration); var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); }
static void Main(string[] args) { var monitorService = new MonitorService(); var serviceHost = new Win32ServiceHost(monitorService); serviceHost.Run(); }
private static void RunAsService(string[] args) { var testService = new IgMarketDataDownloadService(args.Where(a => a != RunAsServiceFlag).ToArray()); var serviceHost = new Win32ServiceHost(testService); serviceHost.Run(); }
private static void RunAsService(string[] args) { var service = Container.GetInstance <Service>(); var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); }
private static void RunAsService(IService service) { var winService = new Service(service); var host = new Win32ServiceHost(winService); host.Run(); }
public static void Main(string[] args) { var service = new KestrelDemoService(); var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); }
public static void Main(string[] args) { var myService = new MyService(); var serviceHost = new Win32ServiceHost(myService); serviceHost.Run(); }
private static void RunAsService(string[] args) { var service = new Service(null); var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); }
private static void RunAsService(string[] args) { var testService = new Service(args.Where(a => a != InteractiveFlag).ToArray()); var serviceHost = new Win32ServiceHost(testService); serviceHost.Run(); }
protected override Result RunCore(Argument[] args) { var cafeServerWindowsService = new CafeServerWindowsService(); var serviceHost = new Win32ServiceHost(cafeServerWindowsService); serviceHost.Run(); return(Result.Successful()); }
static void Main(string[] args) { var myService = new MyService(); var serviceHost = new Win32ServiceHost(myService); File.AppendAllText(MyService.logPath, $"{Environment.NewLine}{DateTime.Now} state: {myService.IsRunning}"); serviceHost.Run(); }
public static void Run(string serviceName, RavenConfiguration configuration, string[] args) { var service = new RavenWin32Service(serviceName, configuration, args); Program.RestartServer = service.Restart; var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); }
protected override Result RunCore(Argument[] args) { Logger.Info($"Creating service host for {_application}"); var windowsService = _windowsServiceCreator(); var serviceHost = new Win32ServiceHost(windowsService); Logger.Debug("Service host created, running"); serviceHost.Run(); Logger.Debug($"Finished running service host for {_application}"); return(Result.Successful()); }
private static void RunAsService(string[] args) { logger.Info("Running as service"); var testService = new AppWin32Service(args.Where(a => a != RunAsServiceFlag).ToArray()); testService.OnStart += Start; testService.OnStop += Stop; var serviceHost = new Win32ServiceHost(testService); serviceHost.Run(); }
public static void Main(string[] args) { var services = new ServiceCollection(); services.AddScoped(typeof(IService), typeof(Service.WindowsService.Jobs.Service)); var builder = services.BuildServiceProvider(); var myService = new MyService(builder); var serviceHost = new Win32ServiceHost(myService); serviceHost.Run(); }
private static int RunAsService(Options options) { if (string.IsNullOrWhiteSpace(options.ServiceName)) { WriteLine("Service name is required for uninstalling", ConsoleColor.Red); return(-1); } var service = new BlipService(options.ServiceName); var serviceHost = new Win32ServiceHost(service); return(serviceHost.Run()); }
private static void RunAsService(string[] args) { try { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); var rweKestrelWebServerService = new KestrelService(args.Where(a => a != RunAsServiceFlag).ToArray()); var rweKestrelWebServerServiceHost = new Win32ServiceHost(rweKestrelWebServerService); rweKestrelWebServerServiceHost.Run(); } catch (Exception e) { Console.WriteLine("Error: '{0}'", e); } }
static void Main(string[] args) { if (args.Contains(RunAsServiceFlag)) { var service = new UniversalDashboardService(); var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); } else { var dashboardManager = new DashboardManager(); dashboardManager.Start(); } }
private static void Run(Settings Set) { try { var serviceHost = new Win32ServiceHost(Set.Service); serviceHost.Run(); } catch (Exception ex) { if (Set.WriteLog) { File.AppendAllText(Set.LogPath, $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ffff")} {Set.ServiceName}({Set.DisplayName}) Started{Environment.NewLine}"); } Console.WriteLine(ex.Message); } }
static void Main(string[] args) { var dontSetExecutionPolicy = args.Contains(NoExecutionPolicy); if (args.Contains(RunAsServiceFlag)) { var service = new UniversalDashboardService(dontSetExecutionPolicy); var serviceHost = new Win32ServiceHost(service); serviceHost.Run(); } else { var dashboardManager = new DashboardManager(dontSetExecutionPolicy); dashboardManager.Start(); } }
//Installed DasMulli //Installed Kestrel static void Main(string[] args) { var host = new ServiceHost(); if (Debugger.IsAttached) { host.Start(null, null); Console.ReadLine(); host.Stop(); } else { var win32Host = new Win32ServiceHost(host); win32Host.Run(); } }
static void Main(string[] args) { CommandLine.Parser.Default.ParseArguments <Options>(args) .WithParsed(opts => { var configBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.Local.json", optional: true); Configuration = configBuilder.Build(); var container = IocConfig(); ICommand cmd = null; switch (opts.Process) { case ProcessToRun.Method1: cmd = container.Resolve <Method1Command>(); break; case ProcessToRun.Method2: Console.WriteLine("Do whatever method two wants"); break; case ProcessToRun.Method3: Console.WriteLine("Do whatever method three wants"); break; } if (cmd != null) { if (opts.RunAsService) { var service = new RunAsService(cmd); var host = new Win32ServiceHost(service); host.Run(); } else { cmd.Execute(); } } }); Console.WriteLine("---------- PRESS ANY KEY TO EXIT ----------"); Console.ReadKey(); }