Example #1
0
        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();
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
 private static int Main(string[] args) => WindowsServiceHost.Run(
     ServiceName,
     DisplayName,
     Description,
     S3SettingsParser.Parse,
     S3IocModule.Create);