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(); }
public void StartWebHost() { if (_WebHost != null) { _WebHost.Stop(); _WebHost.Dispose(); } string URL = "http://localhost"; _WebHost = new NancyHost(new Uri(URL)); _WebHost.Start(); }
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("停止成功"); } }
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(); } }
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); }
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; } }
private void Stop() { _nancyHost.Stop(); _nancyHost.Dispose(); _nancyHost = null; Console.WriteLine("HTTP server stopped"); }
public void TearDown() { Client.Dispose(); host.Dispose(); Directory.SetCurrentDirectory(oldDir); }
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"); }
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"); }
public void Stop() { _realTimeDataServer.Dispose(); _historicalDataBroker.Dispose(); _httpServer.Dispose(); _scheduler.Shutdown(); }
public void Dispose() { ThumbGenerator.Close(); DBUpdateQueue.Close(); host?.Stop(); host?.Dispose(); }
public void Dispose() { logger.Info(" Dispose() Inicializador servico nancy"); if (host != null) { host.Dispose(); } }
public void Stop() { if (_host != null) { _host.Stop(); _host.Dispose(); } }
public void Stop() { _logger.Info("Service shutting down"); _host.Stop(); _host.Dispose(); // code that runs when the Windows Service stops _logger.Info("Service stopped"); }
public void Dispose() { if (_host != null) { _host.Dispose(); _host = null; _serverModule = null; } }
public void Shutdown() { if (_host != null) { _host.Stop(); _host.Dispose(); _host = null; } }
public void Stop() { if (_host != null) { _host.Stop(); _host.Dispose(); } ClearAllState(); }
public void Dispose() { StopHub(); if (_host == null) { return; } _host.Dispose(); }
/// <summary> /// 回收资源 /// </summary> public static void Dispose() { //回收资源 if (_host != null) { _host.Stop(); _host.Dispose(); _host = null; } }
/// <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..."); }
private static void Exit() { Logger.Info() .Message("Closing...") .Write(); _nancyHost.Dispose(); AuthServer.Instance.Dispose(); LogManager.Shutdown(); }
public void Stop() { try { _host1?.Dispose(); } catch (Exception exception) { _logger.InfoFormat(exception, "ConfigurationService stop error"); } }
/// <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); }
private void Stop() { Container.GetInstance <ISlackMessenger>().Post(new SlackMessage { Username = "******", Text = "Service stopped" }); // Close the Nancy web host _webHost.Dispose(); Logger.Debug($"{ServiceName} stopped"); }
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(); }