Stop() public method

public Stop ( ) : void
return void
Ejemplo n.º 1
1
        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);
                }
            }
        }
Ejemplo n.º 2
0
        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
            }
        }
Ejemplo n.º 3
0
        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();
            }
        }
        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();
        }
Ejemplo n.º 5
0
        /// <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();
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        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();
            }
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            try
            {
                var uri = "http://localhost:8888";
                Console.WriteLine(uri);

                XmlConfigurator.Configure();

                ILog logger = LogManager.GetLogger(typeof(Program));
                logger.InfoFormat("Starting DeReader : {0}", uri);

                // initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
                var host = new NancyHost(new Uri(uri));
                host.Start();  // start hosting

                //Under mono if you deamonize a process a Console.ReadLine with 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();
                }

                logger.Info("Stoping DeReader");
                host.Stop();  // stop hosting
            }
            finally
            {
                LogManager.Shutdown();
            }
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
    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 
    }
Ejemplo n.º 12
0
        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!");
        }
Ejemplo n.º 13
0
        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();
        }
Ejemplo n.º 14
0
 public static void Main()
 {
     var host = new NancyHost(new Uri("http://localhost:5150"));
     host.Start();
     Console.ReadLine();
     host.Stop();
 }
Ejemplo n.º 15
0
        private static void Main(string[] args)
        {
            using (var container = Bootstrap())
            {
            #if !DEBUG
                try
            #endif
                {
                    Trace.Listeners.Add(new ConsoleTraceListener());

                    if (args.Length > 0 && args[0] == "--build-index")
                    {
                        var indexer = container.Resolve<MusicIndexer>();
                        indexer.IndexFolder(Settings.Default.LibraryFolder);
                        return;
                    }

                    using (var nancyHost = new NancyHost(new NancyBootstrapper(container), new Uri(Settings.Default.BaseAddress)))
                    {
                        nancyHost.Start();
                        Console.ReadKey();
                        nancyHost.Stop();
                    }
                }
            #if !DEBUG
                catch (Exception e)
                {
                    Trace.WriteLine("Unexpected fatal error, the server was shutdown: " + e.Message);
                }
            #endif
            }
        }
Ejemplo n.º 16
0
        protected override void OnStop()
        {
            host.Stop();
            host.Dispose();

            try
            {
                _cancelSource?.Cancel(false);
                System.Threading.Thread.Sleep(3000);
                HlidacStatu.Util.WebShot.Workers.CancelWorkers();

                _cancelSource?.Dispose();
                //_initializationTask?.Dispose();
            }
            catch (Exception stopException)
            {
                Program.logger.Debug($"stopException {stopException?.ToString()}");

                //log any errors
            }


            HlidacStatu.Util.WebShot.Chrome.TheOnlyStaticInstance.Dispose();
            System.Threading.Thread.Sleep(500);
            //_shutdownEvent.Set();
            //if (!_thread.Join(3000))
            //{ // give the thread 3 seconds to stop
            //    _thread.Abort();
            //}
        }
Ejemplo n.º 17
0
        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();
        }
Ejemplo n.º 18
0
        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!");
            }
        }
Ejemplo n.º 19
0
 static void Main(string[] args)
 {
     var host = new NancyHost(new Uri("http://localhost:8445"), new MyApplicationBootstrapper());
     host.Start();
     Process.Start("http://localhost:8445");
     System.Windows.Forms.Application.Run(new ApplicationIcon());
     host.Stop();
 }
Ejemplo n.º 20
0
 static void Main()
 {
     var host = new NancyHost(new Uri("http://localhost:12345"));
     host.Start();
     Console.Write("Press any key to stop program");
     Console.Read();
     host.Stop();
 }
Ejemplo n.º 21
0
 static void Main(string[] args)
 {
     Host = new NancyHost (CurrentAddress);
     Host.Start ();
     Console.WriteLine ("Nancy is started and listening on {0}...", CurrentAddress);
     while (Console.ReadLine () != "quit");
     Host.Stop ();
 }
Ejemplo n.º 22
0
 public static void Main (string[] args)
 {
     var host = new NancyHost(new Uri("http://localhost:8081"));
     DynamicHub.Storage.StorageService service;
     host.Start();
     Console.ReadLine();
     host.Stop();
 }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            // initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
            var host = new NancyHost(new Uri("http://localhost:12345"));
            host.Start(); // start hosting

            Console.ReadKey();
            host.Stop();  // stop hosting
        }
Ejemplo n.º 24
0
		static void Main(string[] args)
		{
			// initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
			var host = new NancyHost(new Uri(serverUri));
			host.Start(); // start hosting
			Console.ReadLine();
			Console.WriteLine("You are about to close the application.");
			host.Stop();  // stop hosting
		}
Ejemplo n.º 25
0
 public static void Main(string[] args)
 {
     var url = "http://localhost:8081";
     var host = new NancyHost(new Uri(url));
     host.Start();
     Console.WriteLine ("Server now running on: " + url);
     Console.ReadLine ();
     host.Stop();
 }
Ejemplo n.º 26
0
Archivo: Main.cs Proyecto: 3-n/saq
 public static void Main(string[] args)
 {
     SimpleWebQuiz.SimpleWebQuiz stuff;
     StaticConfiguration.DisableCaches = true;
     var host = new NancyHost(new Uri("http://localhost:80"));
     host.Start();
     Console.ReadLine ();
     host.Stop();
 }
Ejemplo n.º 27
0
		static void Main(string[] args)
		{
			var host = new NancyHost(new Uri(ServerUri));
			Console.WriteLine("Listening on " + ServerUri);
			host.Start();
			Console.ReadLine();
			Console.WriteLine("You are about to close the application.");
			host.Stop();
		}
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            #region cmd 파싱
            if (args.Length > 0)
            {
                try
                {
                    port = Convert.ToUInt16(args[0]);
                }
                catch
                {
                    Console.WriteLine("○ 잘못된 인자 \"" + args[0] + "\"");
                    Console.WriteLine("  포트번호를 입력해야합니다. ( ex: 64401 )");
                }
            }
            #endregion

            #region 호스팅 루프
            // NancyHost 인스턴스 초기화 (Nancy.Hosting.Self 패키지 안에있음)
            var uri = new Uri(string.Format("http://localhost:{0}/", port));
            var config = new HostConfiguration();
            config.UrlReservations.CreateAutomatically = true;

            var host = new NancyHost(config, uri);

            try
            {
                // 호스팅 시작
                host.Start();
                Console.WriteLine("● 호스팅 시작 ─ \"" + uri + "\"");

                // Under mono if you deamonize a process a Console.ReadLine with 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.WriteLine("○ 프로세스를 종료하려면 \"" + escapeCmd + "\"를 입력하세요.");
                    while (Console.ReadLine() != escapeCmd) ;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("◎ 예외 발생!");
                Console.WriteLine(e.Message);
                Console.ReadKey(true);
            }
            finally
            {
                // 호스팅 멈춤
                host.Stop();
            }
            #endregion
        }
Ejemplo n.º 29
0
 public static void Main(string[] args)
 {
     var host = new NancyHost(new Uri("http://localhost:11380"), new Bootstrapper());
     host.Start();
     Console.WriteLine("Application started. Hit q to quit. duh.");
     do
     {
     } while (Console.ReadKey(true).Key != ConsoleKey.Q);
     host.Stop();
 }
Ejemplo n.º 30
0
        static void InitializeHost()
        {
            var host = new NancyHost(new Uri("http://localhost:12345"));

            host.Start();

            Console.ReadLine();

            host.Stop();
        }
Ejemplo n.º 31
0
        //Hosts,starts and stops the nancy server using the default bootstrap
        static void Main(string[] args)
        {
            HostConfiguration hostConfigs = new HostConfiguration();

            hostConfigs.UrlReservations.CreateAutomatically = true;
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:9664/"), new DefaultNancyBootstrapper(), hostConfigs);

            nancyHost.Start();
            Console.WriteLine("The Backflipt statistics server is running now!!" + DateTime.Now);
            Console.ReadLine();
            nancyHost.Stop();
        }
Ejemplo n.º 32
0
        static void Main(string[] args)
        {
            HostConfiguration hostConfigs = new HostConfiguration();

            hostConfigs.UrlReservations.CreateAutomatically = true;
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:9664"), new DefaultNancyBootstrapper(), hostConfigs);

            EwsXenLib.Oodly.loggerconfig();
            nancyHost.Start();
            Console.WriteLine("Web server running...");
            Console.ReadLine();
            nancyHost.Stop();
        }
Ejemplo n.º 33
0
        static void Main(string[] args)
        {
            var hostUrl = "http://localhost:" + ConfigurationManager.AppSettings["Port"];
            HostConfiguration hostConfigs = new HostConfiguration();

            hostConfigs.UrlReservations.CreateAutomatically = true;
            var nancyHost = new Nancy.Hosting.Self.NancyHost(hostConfigs, new Uri(hostUrl));

            nancyHost.Start();

            Console.WriteLine("Nancy host listening on " + hostUrl);

            Console.ReadLine();
            nancyHost.Stop();
        }
Ejemplo n.º 34
0
        static void Main(string[] args)
        {
            //DumpKundenTabelle();

            var loConfig = new HostConfiguration {
                AllowChunkedEncoding = false
            };

            loConfig.UrlReservations.CreateAutomatically = true; //Wird Programm unter Admin gestartet braucht man das nicht

            var nancyHost = new Nancy.Hosting.Self.NancyHost(loConfig, new Uri(DOMAIN));

            // start
            nancyHost.Start();
            Console.WriteLine("REST service listening on " + DOMAIN);
            // stop with an <Enter> key press
            Console.ReadLine();
            nancyHost.Stop();
        }
Ejemplo n.º 35
-1
        public static void Main(string[] args)
        {
            Models.Benchmark.Initialize ();
            Models.Configuration.Initialize ();
            Models.Counter.Initialize ();
            Models.Device.Initialize ();
            Models.Project.Initialize ();
            Models.Recipe.Initialize ();
            Models.Revision.Initialize ();
            Models.Run.Initialize ();
            Models.Sample.Initialize ();

            var nancyHost = new NancyHost (new Uri ("http://127.0.0.1:8080/"), new Uri ("http://10.1.12.185:8080/"));

            nancyHost.Start ();

            StaticConfiguration.DisableErrorTraces = false;
            StaticConfiguration.Caching.EnableRuntimeViewUpdates = true;

            Console.WriteLine ("Nancy now listening on http://127.0.0.1:8080/. Press key to stop");

            while (true) {
                if (Console.ReadKey ().Key == ConsoleKey.Enter) {
                    break;
                }

                Thread.Sleep (100);
            }

            nancyHost.Stop ();
            nancyHost.Dispose ();

            Console.WriteLine ("The End;");
        }