当前位置: 首页>>代码示例>>C#>>正文


C# NancyHost.Stop方法代码示例

本文整理汇总了C#中Nancy.Hosting.Self.NancyHost.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# NancyHost.Stop方法的具体用法?C# NancyHost.Stop怎么用?C# NancyHost.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.Hosting.Self.NancyHost的用法示例。


在下文中一共展示了NancyHost.Stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunAsConsoleApp

        private static void RunAsConsoleApp(string[] args)
        {
// Running from the command line
            WriteWelcomeHeader();
#if DEBUG
            Logging.EnableConsoleOutput(true);
#else
            Logging.EnableConsoleOutput(false);
#endif

            var serviceArgs = new ServiceArgs();
            if (CommandLine.Parser.ParseArgumentsWithUsage(args, serviceArgs))
            {
                try
                {
                    var bootstrapper = ServiceBootstrap.GetBootstrapper(serviceArgs);
                    var baseUris = serviceArgs.BaseUris.Select(x => x.EndsWith("/") ? new Uri(x) : new Uri(x + "/")).ToArray();
                    var nancyHost = new NancyHost(bootstrapper, new HostConfiguration {AllowChunkedEncoding = false}, baseUris);
                    Nancy.StaticConfiguration.DisableErrorTraces = !serviceArgs.ShowErrorTraces;
                    nancyHost.Start();
                    Console.ReadLine();
                    nancyHost.Stop();
                }
                catch (BootstrapperException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unhandled exception in server: {0}", ex.Message);
                }
            }
        }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:33,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            var parsedArgs = Parser.Default.ParseArguments<Options> (args);

            if (!parsedArgs.Errors.Any () && parsedArgs.Value != null) {
                var options = parsedArgs.Value;

                var domain = options.Domain ?? ConfigurationManager.AppSettings.Get ("Nancy.Host") ?? "127.0.0.1";
                var port = options.Port ?? ConfigurationManager.AppSettings.Get ("Nancy.Port") ?? "9999";

                var uri = new Uri ("http://" + domain + ":" + port);

                var configuration = new HostConfiguration();
                configuration.UnhandledExceptionCallback = HandleException;

                // initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
                var nancyHost = new NancyHost (new Bootstrapper (), uri);

                nancyHost.Start (); // start hosting

                while (true) {
                    Thread.Sleep (10000000);
                }

                nancyHost.Stop (); // stop hosting
            }
        }
开发者ID:qginformatique,项目名称:GMATechProject,代码行数:27,代码来源:Program.cs

示例3: Main

        public static void Main(string[] args)
        {
            Config.LoadFromAppSettings();
            GenericFileResponse.SafePaths.Add(Config.PackageRepositoryPath);

            HostConfiguration hostConfigs = new HostConfiguration()
            {
                UrlReservations = new UrlReservations() { CreateAutomatically = true }
            };

            using (var host = new NancyHost(new Uri(string.Format("http://localhost:{0}", Config.Port)), new NusharpBootstrapper(), hostConfigs))
            {
                host.Start();

                //Under mono if you daemonize a process a Console.ReadLine will cause an EOF
                //so we need to block another way
                if (args.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
                {
                    Thread.Sleep(Timeout.Infinite);
                }
                else
                {
                    Console.ReadKey();
                }

                host.Stop();
            }
        }
开发者ID:modulexcite,项目名称:Nusharp,代码行数:28,代码来源:Program.cs

示例4: Main

        public static void Main(string[] args)
        {
            const string uri = "http://localhost:8080";
            Console.WriteLine("Iniciando o Nancy em " + uri);

            // Inicializando uma instância do NancyHost
            var host = new NancyHost(new Uri(uri));
            // Inicia a hospedagem
            host.Start();

            // Verifica se está rodando o Mono
            if (Type.GetType("Mono.Runtime") != null)
            {
                // No Mono, os processos irão geralmente executar como serviços
                // - isso permite escutar sinais de término (CTRL + C, shutdown, etc)
                // e finaliza corretamente
                UnixSignal.WaitAny(new[]
                    {
                        new UnixSignal(Signum.SIGINT),
                        new UnixSignal(Signum.SIGTERM),
                        new UnixSignal(Signum.SIGQUIT),
                        new UnixSignal(Signum.SIGHUP)
                    });
            }
            else
            {
                Console.ReadLine();
            }

            Console.WriteLine("Parando o Nancy");
            // Termina a hospedagem
            host.Stop();
        }
开发者ID:netinhoteixeira,项目名称:osticket-cliente-site-demo,代码行数:33,代码来源:Program.cs

示例5: Main

        /// <summary>
        /// Start hosting the application.
        /// </summary>
        /// <param name="arguments">
        /// The arguments.
        /// </param>
        public static void Main(string[] arguments)
        {
            var url = new Uri(ConfigurationManager.AppSettings["HostUrl"]);

            var configuration = new HostConfiguration
            {
                UnhandledExceptionCallback = exception => Console.WriteLine(exception)
            };

            var host = new NancyHost(configuration, url);

            host.Start();

            if (arguments.Any(s => s.Equals("-d", StringComparison.CurrentCultureIgnoreCase)))
            {
                Thread.Sleep(Timeout.Infinite);
            }
            else
            {
                Console.WriteLine("Server running on {0}, press Enter to exit...", url);

                Console.ReadLine();
            }

            host.Stop();
        }
开发者ID:Kumiko,项目名称:Tools,代码行数:32,代码来源:Program.cs

示例6: Run

        public void Run(CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
                return;

            var nancyConfig = new HostConfiguration
            {
                UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                }
            };

            var bootstrapper = new ApiBootstrapper(_repository);

            var host = new NancyHost(bootstrapper, nancyConfig, _baseUri);
            cancellationToken.Register(() =>
            {
                Log.InfoFormat("Stopping Nancy host at \"{0}\".", _baseUri);
                host.Stop();
                Log.InfoFormat("Nancy host at \"{0}\" successfully stopped.", _baseUri);
            });

            Log.InfoFormat(CultureInfo.InvariantCulture, "Starting Nancy host at \"{0}\".", _baseUri);
            host.Start();
        }
开发者ID:sjlbos,项目名称:SENG462_DTS,代码行数:26,代码来源:NancyHostLauncherWorker.cs

示例7: Main

        static void Main(string[] args)
        {
            var host = new NancyHost(new Uri(startUrl));

            Console.WriteLine("Launching Email Visualiser.");
            try
            {
                host.Start();
                Console.WriteLine("Server has launched.");
                Console.WriteLine("Launching browser...");
                Process.Start(startUrl);
                Console.WriteLine("Press any key to stop the server.");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                TextWriter errorWriter = Console.Error; //TODO change to a logger
                errorWriter.WriteLine("------An error has been encountered.------");
                errorWriter.WriteLine(e.Message);
            #if DEBUG
                errorWriter.WriteLine(e.InnerException);
                errorWriter.WriteLine(e.StackTrace);
            #endif
                errorWriter.WriteLine("------The application will now close.------");
            }
            finally
            {
                host.Stop();
            }
        }
开发者ID:TIMBS,项目名称:OutlookParser,代码行数:30,代码来源:Program.cs

示例8: Main

        static void Main(string[] args)
        {
            // Note: The URI must *exactly* match the one specified in the URL ACL.
            // This leads to a problem when you use +, because the Uri constructor doesn't like it.
            var uri = "http://localhost:1234/";
            if (args.Length != 0)
                uri = args[0];

            var stop = new ManualResetEvent(false);
            Console.CancelKeyPress += (sender, e) =>
                {
                    Console.WriteLine("^C");
                    stop.Set();
                };

            var host = new NancyHost(new Uri(uri));
            host.Start();

            Console.WriteLine("Nancy Self Host listening on {0}", uri);
            Console.WriteLine("Press Ctrl+C to quit.");

            stop.WaitOne();

            host.Stop();
        }
开发者ID:rlipscombe,项目名称:nancy-hosting,代码行数:25,代码来源:Program.cs

示例9: Main

        static void Main(params string[] args)
        {
            #if DEBUG
            Assembly.LoadFile(Path.Combine(Directory.GetCurrentDirectory(), "Aqueduct.Appia.Razor.dll"));
            #endif

            var options = new Options();
            ICommandLineParser parser = new CommandLineParser();
            parser.ParseArguments(args, options);

            if (string.IsNullOrEmpty(options.ExportPath) == false)
            {
                var exporter = new HtmlExporter(options.ExportPath,
                                                    new Configuration(),
                                                    new Aqueduct.Appia.Core.Bootstrapper())
                                                    { Verbose = options.Verbose };
                exporter.Initialise();
                exporter.Export();
            }
            else
            {
                var ip = options.Address == "*" ? IPAddress.Any : IPAddress.Parse(options.Address);
                var nancyHost = new NancyHost(ip, options.Port, new Aqueduct.Appia.Core.Bootstrapper());
                nancyHost.Start();

                Console.WriteLine(String.Format("Nancy now listening - navigate to http://{0}:{1}/. Press enter to stop", options.Address, options.Port));
                Console.ReadKey();

                nancyHost.Stop();

                Console.WriteLine("Stopped. Good bye!");
            }
        }
开发者ID:aqueduct,项目名称:Appia,代码行数:33,代码来源:Program.cs

示例10: Run

        public void Run()
        {
            EnsureInstallation();

            foreach (var service in _services)
            {
                Console.WriteLine("Starting service {0}", service.ServiceName);
                service.Start();
            }

            _nancy = new NancyHost(_uris);
            _nancy.Start();

            Console.WriteLine("Running server at {0}", string.Join(", ", _uris
                .Select(u => u.ToString())
            ));

            Console.ReadLine();

            Console.WriteLine("Stopping server");
            _nancy.Stop();

            foreach (var service in _services)
            {
                Console.WriteLine("Stopping service {0}", service.ServiceName);
                service.Stop();
            }
        }
开发者ID:seyyedi,项目名称:remote-mpc,代码行数:28,代码来源:Server.cs

示例11: Main

        static void Main(string[] args)
        {
            BeagleBoneBlack.SetupOverlays();

            TankManager.DmxControl = new DMXControl(10);
            TankManager.DmxLED = new LEDStrip(TankManager.DmxControl);
            TankManager.TreadsLED = new LEDStrip(new LPD8806((5 * 32) * 3, "/dev/spidev1.0"));
            TankManager.BarrelLED = new LEDStrip(new LPD8806(77, "/dev/spidev2.0"));
            TankManager.Sensor = new SpeedSensor("/dev/ttyO1");

            TankManager.StartTheTank();

            Console.WriteLine("Starting Nancy self host");
            NancyHost host = new NancyHost( new Uri("http://localhost:8080"));
            host.Start();

            Console.WriteLine("Awaiting commands");
            ConsoleKeyInfo key = new ConsoleKeyInfo();
            while(key.Key != ConsoleKey.Escape)
            {
                key = Console.ReadKey(true);
            }

            Console.WriteLine("Stopping Nancy");
            host.Stop();  // stop hosting

            TankManager.StopTheTank();
        }
开发者ID:hmflash,项目名称:TikiTankTwo,代码行数:28,代码来源:Program.cs

示例12: Main

    static void Main(string[] args)
    {
      if (args != null && args.Length >= 2)
      {
        if (args[0] == "-conf" && File.Exists(args[1]))
          AppConfig.ChangeAppConfig(args[1]);
      }

      // initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
      string uri = (string)ConfigurationManager.AppSettings["Nancy.Uri"];
      if (string.IsNullOrEmpty(uri))
        throw new Exception("The parameter 'Nancy.Uri' is not specified in .config file.");

      var host = new NancyHost(new Uri(uri), new CustomBootstrapper());
      host.Start(); // start hosting
      Console.WriteLine();
      Console.Write("Service is ready to receive requests on ");

      ConsoleColor prevColor = Console.ForegroundColor;
      Console.ForegroundColor = ConsoleColor.Green;
      Console.WriteLine(uri.ToString());
      Console.ForegroundColor = prevColor;

      Console.ReadKey();
      host.Stop(); // stop hosting 
    }
开发者ID:veikkoeeva,项目名称:MapSurfer.NET-Web,代码行数:26,代码来源:Program.cs

示例13: Main

        public static void Main (string[] args)
        {
            var hostConfiguration = new HostConfiguration
            {
                UrlReservations = new UrlReservations() { CreateAutomatically = true }
            };

            var nancyHost = new NancyHost(hostConfiguration,
                new Uri("http://localhost:8080/"));

            nancyHost.Start();
            
            Console.WriteLine("Nancy now listening at http://localhost:8080/. Press enter to stop");
            ConsoleKeyInfo key = Console.ReadKey();
            if ((int)key.Key == 0) 
            {
                // Mono returns a ConsoleKeyInfo with a Key value of 0 when stdin is redirected
                // See https://bugzilla.xamarin.com/show_bug.cgi?id=12551
                // For now, just sleep, so that we can run in background with nohup
                Thread.Sleep(Timeout.Infinite);
            }
            
            nancyHost.Stop();
            Console.WriteLine("Stopped. Good bye!");
        }
开发者ID:rayokota,项目名称:generator-angular-nancy,代码行数:25,代码来源:_Main.cs

示例14: Main

 public static void Main()
 {
     var host = new NancyHost(new Uri("http://localhost:5150"));
     host.Start();
     Console.ReadLine();
     host.Stop();
 }
开发者ID:Allistairec,项目名称:Nancy.OData,代码行数:7,代码来源:Class1.cs

示例15: Main

        private static void Main(string[] args)
        {
            if (args.Length != 2 && args.Length != 3)
            {
                Console.WriteLine("WelcomePage.WebServer url root-directory [-open]");
                return;
            }

            var url = new Uri(args[0]);
            var rootDirectory = args[1];
            bool openBrowser = args.Length == 3 && args[2].Equals("-open", StringComparison.InvariantCultureIgnoreCase);

            var stop = new ManualResetEvent(false);
            Console.CancelKeyPress += (sender, e) =>
                {
                    Console.WriteLine("^C");
                    stop.Set();
                };

            var bootstrapper = new Bootstrapper(rootDirectory);
            var configuration = new HostConfiguration { RewriteLocalhost = false };
            var host = new NancyHost(bootstrapper, configuration, url);
            host.Start();
            Console.WriteLine("Nancy host listening on '{0}'. Press Ctrl+C to quit.", url);

            if (openBrowser)
                Process.Start(url.ToString());

            stop.WaitOne();

            host.Stop();
        }
开发者ID:rlipscombe,项目名称:vs-welcome-page,代码行数:32,代码来源:Program.cs


注:本文中的Nancy.Hosting.Self.NancyHost.Stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。