refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/pr-master This commit looks good

This commit is contained in:
2025-07-30 17:43:19 -05:00
parent 462a9446bd
commit f8451c5514

View File

@@ -114,25 +114,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
server_(server) { server_(server) {
REPERTORY_USES_FUNCTION_NAME(); 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) { server_->set_socket_options([](auto &&sock) {
#if defined(_WIN32) #if defined(_WIN32)
int enable{1}; int enable{1};
@@ -247,6 +228,32 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
handle_put_settings(req, res); 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 std::atomic<httplib::Server *> this_server{server_};
static const auto quit_handler = [](int /* sig */) { static const auto quit_handler = [](int /* sig */) {
auto *ptr = this_server.load(); auto *ptr = this_server.load();
@@ -264,19 +271,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
#endif // !defined(_WIN32) #endif // !defined(_WIN32)
std::signal(SIGTERM, quit_handler); 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(); event_system::instance().start();
nonce_thread_ = nonce_thread_ =