refactor
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...
Blockstorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-09-15 14:38:30 -05:00
parent 643b5fbe7e
commit 8f2968d695

View File

@@ -882,11 +882,14 @@ void ui_server::start() {
} }
}; };
auto should_launch{true};
lock_data ui_lock(provider_type::unknown, "ui"); lock_data ui_lock(provider_type::unknown, "ui");
auto res = ui_lock.grab_lock(1U); 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}; auto deadline{std::chrono::steady_clock::now() + 30s};
std::string host{"127.0.0.1"}; std::string host{"127.0.0.1"};
auto desired_port{config_->get_api_port()}; auto desired_port{config_->get_api_port()};
@@ -911,7 +914,21 @@ void ui_server::start() {
std::this_thread::sleep_for(250ms); 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]() { std::thread([this]() {
for (const auto &[prov, names] : config_->get_auto_start_list()) { for (const auto &[prov, names] : config_->get_auto_start_list()) {
for (const auto &name : names) { for (const auto &name : names) {
@@ -961,34 +978,8 @@ void ui_server::start() {
} }
}).join(); }).join();
notify_and_unlock(nonce_lock);
if (should_launch) {
launch_ui(); launch_ui();
should_launch = false;
}
server_.listen_after_bind(); 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() { void ui_server::stop() {