From e5251e0f57a9c60465a79a0eef53d3c9b89aef5d Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Fri, 28 Mar 2025 09:40:11 +1300 Subject: [PATCH] chorus_init binary (just setup the database and exit) --- src/bin/chorus_init.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/bin/chorus_init.rs diff --git a/src/bin/chorus_init.rs b/src/bin/chorus_init.rs new file mode 100644 index 0000000..3d12b2e --- /dev/null +++ b/src/bin/chorus_init.rs @@ -0,0 +1,27 @@ +use chorus::error::Error; +use chorus::globals::GLOBALS; +use std::env; + +#[tokio::main] +async fn main() -> Result<(), Error> { + // Get args (config path) + let mut args = env::args(); + if args.len() <= 1 { + panic!("USAGE: chorus "); + } + let _ = args.next(); // ignore program name + let config_path = args.next().unwrap(); + + let config = chorus::load_config(&config_path)?; + + chorus::setup_logging(&config); + + // Log host name + log::info!(target: "Server", "HOSTNAME = {}", config.hostname); + + chorus::setup_store(&config)?; + + let _ = GLOBALS.store.get().unwrap().sync(); + + Ok(()) +}