Skip to main content

spawn_cli

Function spawn_cli 

Source
pub async fn spawn_cli(db: DB, server_start: Instant, shutdown_tx: Sender<bool>)
Expand description

Spawns the CLI in a separate asynchronous task.

The server sits on the main thread/task, whilst the CLI runs on a seperate task to avoid holding the server from handling requests.

§Arguments

  • db - A reference to the database connection.
  • server_start - The instant when the server started, used for uptime calculations.
  • shutdown_tx - A watch channel sender to signal server shutdown.

§Example

let db = DB::new("sqlite:memory:").await.unwrap();
let server_start = Instant::now();
let (shutdown_tx, shutdown_rx) = watch::channel(false);
spawn_cli(db, server_start, shutdown_tx);