From 8d2e05778c827fa400f96d8e6bbb57ca683d9702 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 18 Dec 2019 16:04:56 +0300 Subject: [PATCH] main: Stop http server Currently it's not stopped at all, so calling a REST request shutdown-time may crash things at random places. Fixes: #5702 But it's not the end of the story. Since the server stays up while we are shutting things down, each subsystem should carefully handle the cases when it's half-down, but a request comes. A better solution is to unregister rest verbs eventually, but httpd's rules cannot do it now. Signed-off-by: Pavel Emelyanov --- main.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.cc b/main.cc index 52192549da..fa7294e692 100644 --- a/main.cc +++ b/main.cc @@ -710,6 +710,9 @@ int main(int ac, char** av) { }(); supervisor::notify("starting API server"); ctx.http_server.start("API").get(); + auto stop_http_server = defer_verbose_shutdown("API server", [&ctx] { + ctx.http_server.stop().get(); + }); api::set_server_init(ctx).get(); with_scheduling_group(maintenance_scheduling_group, [&] { return ctx.http_server.listen(socket_address{ip, api_port});