windows shutdown handling and setup changes
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user