コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: TeenService.cs プロジェクト: Delnar/TeenCheckin
        public void StartWebHost()
        {
            if (_WebHost != null)
            {
                _WebHost.Stop();
                _WebHost.Dispose();
            }
            string URL = "http://localhost";

            _WebHost = new NancyHost(new Uri(URL));
            _WebHost.Start();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: ganpengwei/mydemo
        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("停止成功");
            }
        }
コード例 #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);
        }
コード例 #5
0
 public void Dispose()
 {
     if (_isStarted)
     {
         _nancyHost?.Dispose();
     }
 }
コード例 #6
0
ファイル: GrillServer.cs プロジェクト: finnlander/Grill
 public void Dispose()
 {
     Stop();
     _host.Dispose();
     _host = null;
     ConsoleWriter.Info($"Server stopped on :: {ServerAddress} ({_ip})");
 }
コード例 #7
0
 public bool Stop()
 {
     Console.WriteLine("Stopping...");
     _nancyHost.Stop();
     _nancyHost.Dispose();
     return(true);
 }
コード例 #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;
            }
        }
コード例 #9
0
 private void Stop()
 {
     _nancyHost.Stop();
     _nancyHost.Dispose();
     _nancyHost = null;
     Console.WriteLine("HTTP server stopped");
 }
コード例 #10
0
        public void TearDown()
        {
            Client.Dispose();
            host.Dispose();

            Directory.SetCurrentDirectory(oldDir);
        }
コード例 #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");
        }
コード例 #12
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         m_nancyHost.Dispose();
     }
 }
コード例 #13
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            _nancyHost.Stop();
            _nancyHost.Dispose();

            base.OnClosing(e);
        }
コード例 #14
0
        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();
        }
コード例 #15
0
 public void Stop()
 {
     Logger.Info("Stopping Wolfpack WebService...");
     _host.Stop();
     _host.Dispose();
     Logger.Info("Wolfpack WebService stopped");
 }
コード例 #16
0
 public void Stop()
 {
     _realTimeDataServer.Dispose();
     _historicalDataBroker.Dispose();
     _httpServer.Dispose();
     _scheduler.Shutdown();
 }
コード例 #17
0
ファイル: RinDBCommand.cs プロジェクト: Davudi2134/Karuta
 public void Dispose()
 {
     ThumbGenerator.Close();
     DBUpdateQueue.Close();
     host?.Stop();
     host?.Dispose();
 }
コード例 #18
0
 public void Dispose()
 {
     logger.Info(" Dispose() Inicializador servico nancy");
     if (host != null)
     {
         host.Dispose();
     }
 }
コード例 #19
0
 public void Stop()
 {
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
     }
 }
コード例 #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");
        }
コード例 #21
0
 public void Dispose()
 {
     if (_host != null)
     {
         _host.Dispose();
         _host         = null;
         _serverModule = null;
     }
 }
コード例 #22
0
ファイル: HttpServer.cs プロジェクト: WildGenie/Bastet-Legacy
 public void Shutdown()
 {
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
         _host = null;
     }
 }
コード例 #23
0
 public void Stop()
 {
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
     }
     ClearAllState();
 }
コード例 #24
0
        public void Dispose()
        {
            StopHub();

            if (_host == null)
            {
                return;
            }
            _host.Dispose();
        }
コード例 #25
0
 /// <summary>
 /// 回收资源
 /// </summary>
 public static void Dispose()
 {
     //回收资源
     if (_host != null)
     {
         _host.Stop();
         _host.Dispose();
         _host = null;
     }
 }
コード例 #26
0
ファイル: Server.cs プロジェクト: iDilly/sharp
 /// <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...");
 }
コード例 #27
0
        private static void Exit()
        {
            Logger.Info()
            .Message("Closing...")
            .Write();

            _nancyHost.Dispose();
            AuthServer.Instance.Dispose();
            LogManager.Shutdown();
        }
コード例 #28
0
 public void Stop()
 {
     try
     {
         _host1?.Dispose();
     }
     catch (Exception exception)
     {
         _logger.InfoFormat(exception, "ConfigurationService stop error");
     }
 }
コード例 #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);
        }
コード例 #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");
        }
コード例 #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();
        }