refactor
This commit is contained in:
@@ -114,25 +114,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
||||
server_(server) {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
#if defined(_WIN32)
|
||||
if (config_->get_hidden()) {
|
||||
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
|
||||
}
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
std::uint16_t port{};
|
||||
if (not utils::get_next_available_port(config_->get_api_port(), port)) {
|
||||
fmt::println("failed to detect if port is available|{}",
|
||||
config_->get_api_port());
|
||||
return;
|
||||
}
|
||||
|
||||
if (port != config_->get_api_port()) {
|
||||
fmt::println("failed to listen on port|{}|next available|{}",
|
||||
config_->get_api_port(), port);
|
||||
return;
|
||||
}
|
||||
|
||||
server_->set_socket_options([](auto &&sock) {
|
||||
#if defined(_WIN32)
|
||||
int enable{1};
|
||||
@@ -247,6 +228,32 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
||||
handle_put_settings(req, res);
|
||||
});
|
||||
|
||||
#if defined(_WIN32)
|
||||
system(fmt::format(
|
||||
R"(start "Repertory Management Portal" "http://127.0.0.1:{}/ui")",
|
||||
config_->get_api_port())
|
||||
.c_str());
|
||||
#elif defined(__linux__)
|
||||
system(fmt::format(R"(xdg-open "http://127.0.0.1:{}/ui")",
|
||||
config_->get_api_port())
|
||||
.c_str());
|
||||
#else // error
|
||||
build fails here
|
||||
#endif
|
||||
|
||||
std::uint16_t port{};
|
||||
if (not utils::get_next_available_port(config_->get_api_port(), port)) {
|
||||
fmt::println("failed to detect if port is available|{}",
|
||||
config_->get_api_port());
|
||||
return;
|
||||
}
|
||||
|
||||
if (port != config_->get_api_port()) {
|
||||
fmt::println("failed to listen on port|{}|next available|{}",
|
||||
config_->get_api_port(), port);
|
||||
return;
|
||||
}
|
||||
|
||||
static std::atomic<httplib::Server *> this_server{server_};
|
||||
static const auto quit_handler = [](int /* sig */) {
|
||||
auto *ptr = this_server.load();
|
||||
@@ -264,19 +271,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
||||
#endif // !defined(_WIN32)
|
||||
std::signal(SIGTERM, quit_handler);
|
||||
|
||||
#if defined(_WIN32)
|
||||
system(fmt::format(
|
||||
R"(start "Repertory Management Portal" "http://127.0.0.1:{}/ui")",
|
||||
config_->get_api_port())
|
||||
.c_str());
|
||||
#elif defined(__linux__)
|
||||
system(fmt::format(R"(xdg-open "http://127.0.0.1:{}/ui")",
|
||||
config_->get_api_port())
|
||||
.c_str());
|
||||
#else // error
|
||||
build fails here
|
||||
#endif
|
||||
|
||||
event_system::instance().start();
|
||||
|
||||
nonce_thread_ =
|
||||
|
Reference in New Issue
Block a user