Lines
0 %
Functions
Branches
100 %
use exitfailure::ExitFailure;
use server::config::set_system_config;
use std::env;
/// Boot the server the same way the original CLI entrypoint did:
/// install drivers, run migrations, load config. Used by both
/// binaries so the initialization sequence stays identical.
///
/// # Errors
/// Returns an `ExitFailure` if `set_system_config` fails for the optional
/// `setopt` override. Server-boot failures are handled separately:
/// panics from the `boot` join handle surface as task-panic aborts,
/// which is the original behaviour the CLI shipped with.
/// # Panics
/// Panics if `server::start().await` returns a handle that panics,
/// or whose inner task panics, or whose inner `Result` is `Err`.
pub async fn start_server(
database: Option<String>,
setopt: Option<(String, String)>,
) -> Result<(), ExitFailure> {
if let Some(db) = database {
unsafe {
env::set_var("DATABASE_URL", db);
}
// `server::start` already returns the boot task's handle; spawning it again
// only added a third Result layer to unwrap.
server::start().await.await??;
if let Some((field, content)) = setopt {
set_system_config(&field, content.into()).await?;
Ok(())