refactor
All checks were successful
Blockstorage/repertory/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-09-15 12:58:46 -05:00
parent f2f28cea59
commit 6b2bf3ab67

View File

@@ -49,10 +49,12 @@ namespace repertory::ui {
return static_cast<std::int32_t>(exit_code::ui_failed); return static_cast<std::int32_t>(exit_code::ui_failed);
} }
const auto run_ui = [](auto *server) { const auto run_ui = [&]() -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
static std::atomic<ui_server *> active_server{server}; ui_server server(&config);
static std::atomic<ui_server *> active_server{&server};
static const auto quit_handler = [](int /* sig */) { static const auto quit_handler = [](int /* sig */) {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -66,6 +68,8 @@ namespace repertory::ui {
} catch (const std::exception &ex) { } catch (const std::exception &ex) {
utils::error::raise_error(function_name, ex, "failed to stop ui"); utils::error::raise_error(function_name, ex, "failed to stop ui");
} }
repertory::project_cleanup();
}; };
std::signal(SIGINT, quit_handler); std::signal(SIGINT, quit_handler);
@@ -75,24 +79,17 @@ namespace repertory::ui {
std::signal(SIGTERM, quit_handler); std::signal(SIGTERM, quit_handler);
try { try {
server->start(); server.start();
} catch (const std::exception &ex) { } catch (const std::exception &ex) {
utils::error::raise_error(function_name, ex, "failed to start ui"); utils::error::raise_error(function_name, ex, "failed to start ui");
} }
try { quit_handler(SIGTERM);
server->stop(); return 0;
} catch (const std::exception &ex) {
utils::error::raise_error(function_name, ex, "failed to stop ui");
}
repertory::project_cleanup();
}; };
#if defined(_WIN32) #if defined(_WIN32)
ui_server server(&config); return run_ui();
run_ui(&server);
return 0;
#else // !defined(_WIN32) #else // !defined(_WIN32)
repertory::project_cleanup(); repertory::project_cleanup();
@@ -106,9 +103,7 @@ namespace repertory::ui {
return -1; return -1;
} }
ui_server server(&config); return run_ui();
run_ui(&server);
return 0;
}); });
#endif // defined(_WIN32) #endif // defined(_WIN32)
} }