} // Ссылка для сервиса static void Main(string[] args) { try { // Service configure ServiceUrl = @"http://*****:*****@"C:\tmp\ks\"; // путь к служебным файлам (БД, логи) System.IO.Directory.CreateDirectory(_workPath); DbPath = _workPath + @"clientDB.db"; string log_path = _workPath + @"Writter_.log"; // Инициализация сервиса InitDB(DbPath); InitLogger(log_path); InitSoapService(); // Ожидание команды на закрытие сервиса Console.ReadLine(); // Закрываем службу HttpHost.Close(); CloseDB(DbPath); Log.Information("Service stopped"); } catch (Exception e) { Log.Fatal(e.Message); Console.WriteLine(e); Console.ReadLine(); } }
public void Dispose() { if (_host != null) { _host.Close(); } }
static void Main(string[] args) { var host = new HttpHost("http://localhost:8080"); host.Add(new CommandBind(new VerySimpleCommand(), HttpMethod.Get, new UriTemplate("*"))); host.Open(); Console.WriteLine("Server is running, press any key to continue..."); Console.ReadKey(); host.Close(); }
static void Main(string[] args) { var host = new HttpHost("http://localhost:8080"); host.Add(DefaultMethodBasedCommandFactory.GetCommandsFor(typeof(Controller))); host.Open(); Console.WriteLine("Server is running, press any key to continue..."); Console.ReadKey(); host.Close(); }
static void Main(string[] args) { var host = new HttpHost("http://localhost:8080"); host.Add(DefaultMethodBasedCommandFactory.GetCommandsFor(typeof(ToDoController))); host.Open(); Console.WriteLine("Server is running, press any key to continue..."); Console.ReadKey(); host.Close(); }
static void Main(string[] args) { var host = new HttpHost("http://localhost:8080"); host.Add(new CommandBind(new VerySimpleCommand(), HttpMethod.Get, new UriTemplate("*"))); host.Open(); Console.WriteLine("Server is running, press any key to continue..."); Console.ReadKey(); host.Close(); }
public Task UnregisterRoute(Uri route) { string routeKey = route.LocalPath.ToLowerInvariant(); ITriggeredFunctionExecutor executor = null; _functions.TryRemove(routeKey, out executor); if (_functions.Count == 0) { // routes are only unregistered when function listeners are // shutting down, so we ref count here and when the last one // is removed, we stop the server _httpHost.Close(); } return(Task.FromResult(0)); }
public async Task IsServerRunningPositiveTest() { var port = GetAvailablePort(); using (var httpHost = new HttpHost(port)) { await httpHost.OpenAsync(r => { var url = r.RequestUri; HttpResponseMessage response; if (url.AbsolutePath == "/") { response = new HttpResponseMessage(HttpStatusCode.OK); } else if (url.AbsolutePath.Equals("/admin/host/status", StringComparison.OrdinalIgnoreCase)) { response = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(new HostStatus()), Encoding.UTF8, "application/json") }; } else { response = new HttpResponseMessage(HttpStatusCode.InternalServerError); } return(Task.FromResult(response)); }); var uri = new Uri($"http://localhost:{port}"); var result = await uri.IsServerRunningAsync(); result.Should().BeTrue(because: "Server is running"); httpHost.Close(); } }