static void Main(string[] args) { if (args != null && args.Length == 1 && args[0].Length > 1 && (args[0][0] == '-' || args[0][0] == '/')) { switch (args[0].Substring(1).ToLower()) { default: break; case "install": case "i": SelfInstaller.InstallMe(); break; case "uninstall": case "u": SelfInstaller.UninstallMe(); break; case "console": case "c": ConsoleServiceHost.StartHost(args); break; } } else { WindowsServiceHost.StartHost(); } }
/// <summary> /// Create the correct service host according to the running environment. /// </summary> /// <returns> /// The created service host. /// </returns> private static IHost CreateHost() { IHost host = null; if (IsHosted()) { host = new HostedServiceHost(); } else if (ShouldRunAsDaemonOrService()) { if (IsWindows()) { host = new WindowsServiceHost(); } if (IsUnixOrMacOsx()) { host = new DaemonHost(); } } else { host = new ConsoleHost(); } return(host); }
private static int Main(string[] args) => WindowsServiceHost.Run( ServiceName, DisplayName, Description, S3SettingsParser.Parse, S3IocModule.Create);