Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            Console.CancelKeyPress += (s, e) =>
            {
                e.Cancel = true;
                exitLatch.Set();
            };

            try
            {
                var options = new Options();
                if (Parser.Default.ParseArguments(args, options))
                {
                    log.Info("Port:", options.Port);
                    log.Info("Webroot:", options.WebRoot);
                    log.Info("Runtime:", options.RuntimeVersion);
                }
                else
                {
                    Environment.Exit(1);
                }

                ConfigSettings settings;
                var configGenerator = new ConfigGenerator(options.WebRoot);
                switch (options.RuntimeVersion)
                {
                    case "2":
                    case "2.0":
                        settings = configGenerator.Create(
                            options.Port,
                            Constants.FrameworkPaths.TwoDotZeroWebConfig,
                            Constants.RuntimeVersion.VersionTwoDotZero,
                            Constants.PipelineMode.Integrated, options.UserName, options.Password);
                        break;
                    default:
                        settings = configGenerator.Create(
                            options.Port,
                            Constants.FrameworkPaths.FourDotZeroWebConfig,
                            Constants.RuntimeVersion.VersionFourDotZero,
                            Constants.PipelineMode.Integrated, options.UserName, options.Password);
                        break;
                }

                log.Info("starting web server instance...");
                using (var webServer = new WebServer(settings))
                {
                    webServer.Start();
                    Console.WriteLine("Server Started.... press CTRL + C to stop");

                    StartInBrowser(options);

                    exitLatch.WaitOne();
                    Console.WriteLine("Server shutting down, please wait...");
                    webServer.Stop();
                }

                if (File.Exists("iishost_stop"))
                {
                    File.Delete("iishost_stop");
                }
            }
            catch (Exception ex)
            {
                log.ErrorException("Error on startup.", ex);
                Environment.Exit(2);
            }
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Console.CancelKeyPress += (s, e) =>
            {
                e.Cancel = true;
                exitLatch.Set();
            };

            try
            {
                var options = new Options();
                if (Parser.Default.ParseArguments(args, options))
                {
                    log.Info("Port:", options.Port);
                    log.Info("Webroot:", options.WebRoot);
                    log.Info("Runtime:", options.RuntimeVersion);
                }
                else
                {
                    Environment.Exit(1);
                }

                ConfigSettings settings;
                var            configGenerator = new ConfigGenerator(options.WebRoot);
                switch (options.RuntimeVersion)
                {
                case "2":
                case "2.0":
                    settings = configGenerator.Create(
                        options.Port,
                        Constants.FrameworkPaths.TwoDotZeroWebConfig,
                        Constants.RuntimeVersion.VersionTwoDotZero,
                        Constants.PipelineMode.Integrated, options.UserName, options.Password);
                    break;

                default:
                    settings = configGenerator.Create(
                        options.Port,
                        Constants.FrameworkPaths.FourDotZeroWebConfig,
                        Constants.RuntimeVersion.VersionFourDotZero,
                        Constants.PipelineMode.Integrated, options.UserName, options.Password);
                    break;
                }

                log.Info("starting web server instance...");
                using (var webServer = new WebServer(settings))
                {
                    webServer.Start();
                    Console.WriteLine("Server Started.... press CTRL + C to stop");

                    StartInBrowser(options);

                    exitLatch.WaitOne();
                    Console.WriteLine("Server shutting down, please wait...");
                    webServer.Stop();
                }

                if (File.Exists("iishost_stop"))
                {
                    File.Delete("iishost_stop");
                }
            }
            catch (Exception ex)
            {
                log.ErrorException("Error on startup.", ex);
                Environment.Exit(2);
            }
        }