MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / init_hq_server

Function init_hq_server

crates/hyperqueue/src/server/bootstrap.rs:62–77  ·  view source on GitHub ↗

This function initializes the HQ server. It takes a path to a directory and tries to find metadata of a running HQ server either directly inside the directory or in a path linked to by a symlink named [`SYMLINK_PATH`]. If no metadata is found or the metadata links to a server that seems to be offline, a new server will be started. If an already running server is found, an error will be returned

(
    gsettings: &GlobalSettings,
    server_cfg: ServerConfig,
)

Source from the content-addressed store, hash-verified

60///
61/// If an already running server is found, an error will be returned.
62pub async fn init_hq_server(
63 gsettings: &GlobalSettings,
64 server_cfg: ServerConfig,
65) -> anyhow::Result<()> {
66 match get_server_status(gsettings.server_directory()).await {
67 Err(_) | Ok(ServerStatus::Offline) => {
68 log::info!("No online server found, starting a new server");
69 start_server(gsettings, server_cfg).await
70 }
71 Ok(ServerStatus::Online) => anyhow::bail!(
72 "Server at {0} is already online, please stop it first using \
73 `hq server stop --server-dir {0}`",
74 gsettings.server_directory().display()
75 ),
76 }
77}
78
79pub async fn get_client_session(server_directory: &Path) -> anyhow::Result<ClientSession> {
80 let default_home = default_server_directory();

Callers 1

start_serverFunction · 0.85

Calls 3

get_server_statusFunction · 0.85
server_directoryMethod · 0.80
start_serverFunction · 0.70

Tested by

no test coverage detected