added signal handler
This commit is contained in:
parent
0e21d93bb3
commit
722357388c
@ -282,6 +282,7 @@ enum class exit_code : std::int32_t {
|
|||||||
unpin_failed = -17,
|
unpin_failed = -17,
|
||||||
init_failed = -18,
|
init_failed = -18,
|
||||||
ui_mount_failed = -19,
|
ui_mount_failed = -19,
|
||||||
|
exception = -20,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum http_error_codes : std::int32_t {
|
enum http_error_codes : std::int32_t {
|
||||||
|
@ -146,10 +146,17 @@ auto main(int argc, char **argv) -> int {
|
|||||||
(res == exit_code::option_not_found) &&
|
(res == exit_code::option_not_found) &&
|
||||||
(idx < utils::cli::options::option_list.size());
|
(idx < utils::cli::options::option_list.size());
|
||||||
idx++) {
|
idx++) {
|
||||||
res = cli::actions::perform_action(
|
try {
|
||||||
utils::cli::options::option_list[idx], args, data_directory, prov,
|
res = cli::actions::perform_action(
|
||||||
unique_id, user, password);
|
utils::cli::options::option_list[idx], args, data_directory, prov,
|
||||||
|
unique_id, user, password);
|
||||||
|
} catch (const std::exception &ex) {
|
||||||
|
res = exit_code::exception;
|
||||||
|
} catch (...) {
|
||||||
|
res = exit_code::exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == exit_code::option_not_found) {
|
if (res == exit_code::option_not_found) {
|
||||||
res = cli::actions::mount(args, data_directory, mount_result, prov,
|
res = cli::actions::mount(args, data_directory, mount_result, prov,
|
||||||
remote_host, remote_port, unique_id);
|
remote_host, remote_port, unique_id);
|
||||||
|
@ -69,6 +69,16 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
|||||||
});
|
});
|
||||||
|
|
||||||
event_system::instance().start();
|
event_system::instance().start();
|
||||||
|
|
||||||
|
static auto *this_server{server_};
|
||||||
|
static const auto quit_handler = [](int /* sig */) { this_server->stop(); };
|
||||||
|
|
||||||
|
std::signal(SIGINT, quit_handler);
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
std::signal(SIGQUIT, quit_handler);
|
||||||
|
#endif // !defined(_WIN32)
|
||||||
|
std::signal(SIGTERM, quit_handler);
|
||||||
|
|
||||||
server_->listen("127.0.0.1", config_->get_api_port());
|
server_->listen("127.0.0.1", config_->get_api_port());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user