Compare commits
2 Commits
b93e2978b0
...
abd7e24b5e
Author | SHA1 | Date | |
---|---|---|---|
abd7e24b5e | |||
462ebe6fcf |
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user