예제 #1
0
        }                                             // Ссылка для сервиса

        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();
            }
        }
예제 #2
0
 public void Dispose()
 {
     if (_host != null)
     {
         _host.Close();
     }
 }
예제 #3
0
 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();
 }
예제 #4
0
 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();
 }
예제 #5
0
        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();
        }
예제 #6
0
        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));
        }
예제 #8
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();
            }
        }