private void Restart()
        {
            //we stop the current host and dispose it then create a new one.
            //we do this in case the service is not authorised to run under the new user
            _NancyHost.Stop();
            _NancyHost.Dispose();

            _NancyHost = CreateHost();
            _NancyHost.Start();
        }
Example #2
0
        public void StartWebHost()
        {
            if (_WebHost != null)
            {
                _WebHost.Stop();
                _WebHost.Dispose();
            }
            string URL = "http://localhost";

            _WebHost = new NancyHost(new Uri(URL));
            _WebHost.Start();
        }
Example #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("你确定要停止Nancy吗!", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (result == DialogResult.OK)
            {
                if (_host != null)
                {
                    _host.Stop();
                    _host.Dispose();
                    _host = null;
                }
                MessageBox.Show("停止成功");
            }
        }
Example #4
0
        public bool Stop(HostControl hostControl)
        {
            log.Info("stopping");

            stopEvent.Set();

            if (publisherTimer != null)
            {
                publisherTimer.Dispose();
            }

            if (udpDatagramReader != null)
            {
                udpDatagramReader.Dispose();
            }

            if (nancyHost != null)
            {
                log.Info("stopping NancyHost");

                nancyHost.Dispose();

                log.Info("stopped NancyHost");
            } // if

            log.Info("stopped");

            return(true);
        }
 public void Dispose()
 {
     if (_isStarted)
     {
         _nancyHost?.Dispose();
     }
 }
Example #6
0
 public void Dispose()
 {
     Stop();
     _host.Dispose();
     _host = null;
     ConsoleWriter.Info($"Server stopped on :: {ServerAddress} ({_ip})");
 }
 public bool Stop()
 {
     Console.WriteLine("Stopping...");
     _nancyHost.Stop();
     _nancyHost.Dispose();
     return(true);
 }
Example #8
0
        public void Stop()
        {
            Log.Info("ArgusTV.Recorder.MediaPortalTvServer: Stop");

            if (GlobalServiceProvider.Instance.IsRegistered <ITvServerEvent>())
            {
                GlobalServiceProvider.Instance.Get <ITvServerEvent>().OnTvServerEvent -= events_OnTvServerEvent;
            }

            if (GlobalServiceProvider.Instance.IsRegistered <IPowerEventHandler>())
            {
                GlobalServiceProvider.Instance.Get <IPowerEventHandler>().RemovePowerEventHandler(_powerEventHandler);
                Log.Debug("ArgusTV.Recorder.MediaPortalTvServer: Unregistered OnPowerEvent with TV Server");
            }

            if (_dvbEpgThread != null)
            {
                _dvbEpgThread.Stop(true);
                _dvbEpgThread = null;
            }
            if (_recorderRestHost != null)
            {
                _recorderRestHost.Stop();
                TvServerRecorderModule.DisposeModule();
                _recorderRestHost.Dispose();
                _recorderRestHost = null;
            }
        }
Example #9
0
 private void Stop()
 {
     _nancyHost.Stop();
     _nancyHost.Dispose();
     _nancyHost = null;
     Console.WriteLine("HTTP server stopped");
 }
Example #10
0
        public void TearDown()
        {
            Client.Dispose();
            host.Dispose();

            Directory.SetCurrentDirectory(oldDir);
        }
Example #11
0
        public static void Main(string[] args)
        {
            // Start web server
            Console.WriteLine("Press enter to terminate server");
            HostConfiguration hc = new HostConfiguration();

            hc.UrlReservations.CreateAutomatically = true;
            var host = new NancyHost(hc, new Uri("http://localhost:8888"));

            host.Start();

            //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();
            }

            host.Stop();
            host.Dispose();
            Console.WriteLine("Server terminated");
        }
Example #12
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         m_nancyHost.Dispose();
     }
 }
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            _nancyHost.Stop();
            _nancyHost.Dispose();

            base.OnClosing(e);
        }
        static void Main(string[] args)
        {
            var config = new HostConfiguration();

            //config.UrlReservations.CreateAutomatically = true;
            config.RewriteLocalhost = false;

            var bootstrapper = new Bootstrapper();

            host = new NancyHost(bootstrapper, config, baseUri);

            for (int i = 0; ; i++)
            {
                try
                {
                    host.Start();
                    break;
                }
                catch (HttpListenerException ex)
                {
                    // Error 183 happens when the HttpListener fails to listen on the provided Uri
                    if (ex.ErrorCode != 183 || i >= 10)
                    {
                        throw;
                    }

                    // Close the already running instance
                    try
                    {
                        new WebClient().DownloadString(new Uri(baseUri, "/Close"));
                        System.Threading.Thread.Sleep(40); // Feels like enough :P
                    }
                    catch { }
                }
            }

            Console.WriteLine("Your application is running on: " + baseUri);
            Console.WriteLine("You can type relative URIs to test routes, or enter an empty line to exit");

            var engine = bootstrapper.GetEngine();

            while (true)
            {
                var line = Console.ReadLine();
                if (line == "")
                {
                    break;
                }

                var req = new Request("GET", new Url(baseUri + line));
                var res = engine.HandleRequest(req).Response;

                Console.WriteLine("Response Code: " + res.StatusCode);
                res.Contents(Console.OpenStandardOutput());
                Console.WriteLine();
            }

            ProcModule.KillAllProcs();
            host.Dispose();
        }
 public void Stop()
 {
     Logger.Info("Stopping Wolfpack WebService...");
     _host.Stop();
     _host.Dispose();
     Logger.Info("Wolfpack WebService stopped");
 }
Example #16
0
 public void Stop()
 {
     _realTimeDataServer.Dispose();
     _historicalDataBroker.Dispose();
     _httpServer.Dispose();
     _scheduler.Shutdown();
 }
Example #17
0
 public void Dispose()
 {
     ThumbGenerator.Close();
     DBUpdateQueue.Close();
     host?.Stop();
     host?.Dispose();
 }
Example #18
0
 public void Dispose()
 {
     logger.Info(" Dispose() Inicializador servico nancy");
     if (host != null)
     {
         host.Dispose();
     }
 }
Example #19
0
 public void Stop()
 {
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
     }
 }
Example #20
0
        public void Stop()
        {
            _logger.Info("Service shutting down");
            _host.Stop();
            _host.Dispose();

            // code that runs when the Windows Service stops
            _logger.Info("Service stopped");
        }
Example #21
0
 public void Dispose()
 {
     if (_host != null)
     {
         _host.Dispose();
         _host         = null;
         _serverModule = null;
     }
 }
Example #22
0
 public void Shutdown()
 {
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
         _host = null;
     }
 }
Example #23
0
 public void Stop()
 {
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
     }
     ClearAllState();
 }
Example #24
0
        public void Dispose()
        {
            StopHub();

            if (_host == null)
            {
                return;
            }
            _host.Dispose();
        }
Example #25
0
 /// <summary>
 /// 回收资源
 /// </summary>
 public static void Dispose()
 {
     //回收资源
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
         _host = null;
     }
 }
Example #26
0
 /// <summary>
 /// This method is used for disposal of the class instance, as implemented by the IDisposable interface.
 /// </summary>
 public void Dispose()
 {
     log.Info("Stopping & disposing Server...");
     Utils.Invoke(false, () => {
         Dispatch = false;
         m_nancy.Stop();
         m_nancy.Dispose();
     });
     log.Info("Server stopped & disposed...");
 }
Example #27
0
        private static void Exit()
        {
            Logger.Info()
            .Message("Closing...")
            .Write();

            _nancyHost.Dispose();
            AuthServer.Instance.Dispose();
            LogManager.Shutdown();
        }
Example #28
0
 public void Stop()
 {
     try
     {
         _host1?.Dispose();
     }
     catch (Exception exception)
     {
         _logger.InfoFormat(exception, "ConfigurationService stop error");
     }
 }
Example #29
0
        /// <summary>
        ///     Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;
                this.Shutdown();
                _server.Dispose();
            }

            GC.SuppressFinalize(this);
        }
Example #30
0
        private void Stop()
        {
            Container.GetInstance <ISlackMessenger>().Post(new SlackMessage {
                Username = "******", Text = "Service stopped"
            });

            // Close the Nancy web host
            _webHost.Dispose();

            Logger.Debug($"{ServiceName} stopped");
        }
Example #31
0
        public void Should_not_throw_when_disposed_without_starting()
        {
            // Given
            var bootstrapperMock = A.Fake<INancyBootstrapper>();
            var host = new NancyHost(new Uri("http://localhost/"), bootstrapperMock);

            // When
            host.Dispose();

            // Then
            A.CallTo(() => bootstrapperMock.Dispose()).MustHaveHappened();
        }