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 <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2019-12-18 16:04:56 +03:00
parent 9211df2cdf
commit 8d2e05778c

View File

@@ -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});