Compare commits

...

2 Commits

Author SHA1 Message Date
abd7e24b5e refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-03-15 19:20:58 -05:00
462ebe6fcf detect port availability 2025-03-15 19:18:35 -05:00

View File

@ -26,6 +26,7 @@
#include "rpc/common.hpp"
#include "types/repertory.hpp"
#include "ui/mgmt_app_config.hpp"
#include "utils/common.hpp"
#include "utils/error_utils.hpp"
#include "utils/file.hpp"
#include "utils/path.hpp"
@ -112,8 +113,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
handle_put_set_value_by_name(req, res);
});
event_system::instance().start();
static std::atomic<httplib::Server *> this_server{server_};
static const auto quit_handler = [](int /* sig */) {
auto *ptr = this_server.load();
@ -144,6 +143,21 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
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;
}
event_system::instance().start();
server_->listen("127.0.0.1", config_->get_api_port());
this_server = nullptr;
}