refactor
This commit is contained in:
@@ -882,11 +882,14 @@ void ui_server::start() {
|
||||
}
|
||||
};
|
||||
|
||||
auto should_launch{true};
|
||||
|
||||
lock_data ui_lock(provider_type::unknown, "ui");
|
||||
auto res = ui_lock.grab_lock(1U);
|
||||
if (res == lock_result::success) {
|
||||
if (res != lock_result::success) {
|
||||
notify_and_unlock(nonce_lock);
|
||||
launch_ui();
|
||||
return;
|
||||
}
|
||||
|
||||
auto deadline{std::chrono::steady_clock::now() + 30s};
|
||||
std::string host{"127.0.0.1"};
|
||||
auto desired_port{config_->get_api_port()};
|
||||
@@ -911,7 +914,21 @@ void ui_server::start() {
|
||||
std::this_thread::sleep_for(250ms);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
if (not success) {
|
||||
utils::error::raise_error(function_name,
|
||||
utils::error::create_error_message({
|
||||
"bind timeout (port in use)",
|
||||
"host",
|
||||
host,
|
||||
"port",
|
||||
std::to_string(desired_port),
|
||||
}));
|
||||
notify_and_unlock(nonce_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
notify_and_unlock(nonce_lock);
|
||||
|
||||
std::thread([this]() {
|
||||
for (const auto &[prov, names] : config_->get_auto_start_list()) {
|
||||
for (const auto &name : names) {
|
||||
@@ -961,34 +978,8 @@ void ui_server::start() {
|
||||
}
|
||||
}).join();
|
||||
|
||||
notify_and_unlock(nonce_lock);
|
||||
|
||||
if (should_launch) {
|
||||
launch_ui();
|
||||
should_launch = false;
|
||||
}
|
||||
|
||||
server_.listen_after_bind();
|
||||
return;
|
||||
}
|
||||
|
||||
utils::error::raise_error(function_name,
|
||||
utils::error::create_error_message({
|
||||
"bind timeout (port in use)",
|
||||
"host",
|
||||
host,
|
||||
"port",
|
||||
std::to_string(desired_port),
|
||||
}));
|
||||
should_launch = false;
|
||||
}
|
||||
|
||||
notify_and_unlock(nonce_lock);
|
||||
if (not should_launch) {
|
||||
return;
|
||||
}
|
||||
|
||||
launch_ui();
|
||||
}
|
||||
|
||||
void ui_server::stop() {
|
||||
|
Reference in New Issue
Block a user