コード例 #1
0
ファイル: Program.cs プロジェクト: phho/windows_app_lifecycle
        private static int Main(string[] args)
        {
            Console.CancelKeyPress += (s, e) =>
            {
                e.Cancel = true;
                exitLatch.Set();
            };

            var exitCode = 0;
            try
            {
                var options = new Options();
                options.Parse(args);

                log.Info("Port:{0}", options.Port);
                log.Info("Webroot:{0}", options.WebRoot);

                var configGenerator = new ConfigGenerator(options.WebRoot);
                var settings = configGenerator.Create(
                    options.Port,
                    Constants.FrameworkPaths.FourDotZeroWebConfig,
                    Constants.RuntimeVersion.VersionFourDotZero,
                    Constants.PipelineMode.Integrated,
                    null,
                    null);

                using (var webServer = new WebServer(settings))
                {
                    exitCode = RunWebServer(webServer, log, exitLatch);
                }
            }
            catch (Exception ex)
            {
                log.ErrorException("Error on startup.", ex);
                exitCode = 1;
            }

            return exitCode;
        }