windows shutdown handling and setup changes
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2025-09-08 11:03:38 -05:00
parent ba21676c2b
commit 1ed322b0c7
3 changed files with 78 additions and 8 deletions

View File

@@ -276,13 +276,16 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
static std::atomic<httplib::Server *> this_server{server_};
static const auto quit_handler = [](int /* sig */) {
auto *ptr = this_server.load();
auto *ptr = this_server.exchange(nullptr);
if (ptr == nullptr) {
return;
}
this_server = nullptr;
#if defined(_WIN32)
std::jthread([ptr]() { ptr->stop(); });
#else // !defined(_WIN32)
ptr->stop();
#endif // defined(_WIN32)
};
std::signal(SIGINT, quit_handler);
@@ -348,10 +351,7 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
auto_mount.join();
server_->listen("127.0.0.1", config_->get_api_port());
if (this_server != nullptr) {
this_server = nullptr;
server_->stop();
}
quit_handler(SIGTERM);
}
handlers::~handlers() {