diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f7721b8..b2dcb646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,10 @@ - Update watchvalue integration tests - Expose the is_shutdown API: https://gitlab.com/veilid/veilid/-/merge_requests/392 +- veilid-server: + - Put tokio-console behind a feature flag. Closed issue #274: https://gitlab.com/veilid/veilid/-/issues/274 + - Fixed 'daemon' mode `-d` option. Closed issue #360: https://gitlab.com/veilid/veilid/-/issues/360 + - veilid-wasm: - **Breaking** Properly generate TypeScript types for `ValueSubkeyRangeSet`, which would previously resolve to `any`. This is breaking since it can cause type errors to correctly surface in existing applications. ([!397](https://gitlab.com/veilid/veilid/-/merge_requests/397)) - **Breaking** `startupCore()` and `defaultConfig()` now use config objects instead of stringified JSON. diff --git a/veilid-server/Cargo.toml b/veilid-server/Cargo.toml index 71f99f30..dd5d6f41 100644 --- a/veilid-server/Cargo.toml +++ b/veilid-server/Cargo.toml @@ -42,13 +42,13 @@ rt-tokio = [ "tokio-stream", "tokio-util", "opentelemetry_sdk/rt-tokio", - "console-subscriber", ] tracking = ["veilid-core/tracking"] debug-json-api = [] debug-locks = ["veilid-core/debug-locks"] perfetto = ["tracing-perfetto"] flame = ["tracing-flame"] +tokio-console = ["rt-tokio", "console-subscriber"] geolocation = ["veilid-core/geolocation"] diff --git a/veilid-server/src/main.rs b/veilid-server/src/main.rs index f2e48f44..471829e5 100644 --- a/veilid-server/src/main.rs +++ b/veilid-server/src/main.rs @@ -38,12 +38,8 @@ pub struct Logging { #[command(author, version, about)] pub struct CmdlineArgs { /// Run in daemon mode in the background - #[arg(short, long)] - daemon: bool, - - /// Run in the foreground - #[arg(short, long)] - foreground: bool, + #[arg(short, long, value_name = "BOOL", num_args=0..=1, require_equals=true, default_missing_value = "true")] + daemon: Option, /// Specify a configuration file to use #[arg(short, long, value_name = "FILE", default_value = OsString::from(Settings::get_default_veilid_server_conf_path()))] @@ -163,7 +159,7 @@ pub struct CmdlineArgs { wait_for_debug: bool, /// Enable tokio console - #[cfg(feature = "rt-tokio")] + #[cfg(feature = "tokio-console")] #[arg(long)] console: bool, @@ -205,12 +201,13 @@ fn main() -> EyreResult<()> { let mut settingsrw = settings.write(); // Set config from command line - if args.daemon { - settingsrw.daemon.enabled = true; - settingsrw.logging.terminal.enabled = false; - } - if args.foreground { - settingsrw.daemon.enabled = false; + if let Some(daemon) = args.daemon { + if daemon { + settingsrw.daemon.enabled = true; + settingsrw.logging.terminal.enabled = false; + } else { + settingsrw.daemon.enabled = false; + } } if args.logging.debug { settingsrw.logging.terminal.enabled = true; @@ -376,7 +373,7 @@ fn main() -> EyreResult<()> { ); } - #[cfg(feature = "rt-tokio")] + #[cfg(feature = "tokio-console")] if args.console { settingsrw.logging.console.enabled = true; } @@ -405,7 +402,14 @@ fn main() -> EyreResult<()> { if let Some((k, v)) = set_config.split_once('=') { let k = k.trim(); let v = v.trim(); - settings.set(k, v)?; + if let Err(e) = settings.set(k, v) { + // Try again with value quoted as string, since that is a common thing to do + let strv = json::stringify(v); + if settings.set(k, &strv).is_err() { + // Return original error + return Err(e); + } + } } } diff --git a/veilid-server/src/settings.rs b/veilid-server/src/settings.rs index 06c58b1d..70bcfcb5 100644 --- a/veilid-server/src/settings.rs +++ b/veilid-server/src/settings.rs @@ -575,7 +575,7 @@ pub struct Logging { pub flame: Flame, #[cfg(all(unix, feature = "perfetto"))] pub perfetto: Perfetto, - #[cfg(feature = "rt-tokio")] + #[cfg(feature = "tokio-console")] pub console: Console, } @@ -1068,11 +1068,21 @@ impl Settings { } set_config_value!(inner.daemon.enabled, value); + set_config_value!(inner.daemon.pid_file, value); + set_config_value!(inner.daemon.chroot, value); + set_config_value!(inner.daemon.working_directory, value); + set_config_value!(inner.daemon.user, value); + set_config_value!(inner.daemon.group, value); + set_config_value!(inner.daemon.stdout_file, value); + set_config_value!(inner.daemon.stderr_file, value); + set_config_value!(inner.client_api.ipc_enabled, value); set_config_value!(inner.client_api.ipc_directory, value); set_config_value!(inner.client_api.network_enabled, value); set_config_value!(inner.client_api.listen_address, value); + set_config_value!(inner.auto_attach, value); + set_config_value!(inner.logging.system.enabled, value); set_config_value!(inner.logging.system.level, value); set_config_value!(inner.logging.system.ignore_log_targets, value); @@ -1104,7 +1114,7 @@ impl Settings { set_config_value!(inner.logging.perfetto.enabled, value); set_config_value!(inner.logging.perfetto.path, value); } - #[cfg(feature = "rt-tokio")] + #[cfg(feature = "tokio-console")] set_config_value!(inner.logging.console.enabled, value); set_config_value!(inner.testing.subnode_index, value); #[cfg(feature = "virtual-network")] @@ -1770,6 +1780,7 @@ mod tests { assert!(!s.logging.perfetto.enabled); assert_eq!(s.logging.perfetto.path, ""); } + #[cfg(feature = "tokio-console")] assert!(!s.logging.console.enabled); assert_eq!(s.testing.subnode_index, 0); #[cfg(feature = "virtual-network")] diff --git a/veilid-server/src/unix.rs b/veilid-server/src/unix.rs index af0d65f8..436465f5 100644 --- a/veilid-server/src/unix.rs +++ b/veilid-server/src/unix.rs @@ -96,14 +96,14 @@ pub fn run_daemon(settings: Settings, _args: CmdlineArgs) -> EyreResult<()> { daemon }; + // Daemonize + daemon.start().wrap_err("Failed to daemonize")?; + // Now, run the server block_on(async { // Init combined console/file logger let veilid_logs = VeilidLogs::setup(settings.clone())?; - // Daemonize - daemon.start().wrap_err("Failed to daemonize")?; - run_veilid_server_with_signals(settings, ServerMode::Normal, veilid_logs).await }) } diff --git a/veilid-server/src/veilid_logs.rs b/veilid-server/src/veilid_logs.rs index f34928c3..684dd7f3 100644 --- a/veilid-server/src/veilid_logs.rs +++ b/veilid-server/src/veilid_logs.rs @@ -1,7 +1,7 @@ use crate::settings::*; use crate::*; use cfg_if::*; -#[cfg(feature = "rt-tokio")] +#[cfg(feature = "tokio-console")] use console_subscriber::ConsoleLayer; cfg_if::cfg_if! { @@ -67,7 +67,7 @@ impl VeilidLogs { let mut fields_to_strip = HashSet::<&'static str>::new(); fields_to_strip.insert(VEILID_LOG_KEY_FIELD); - #[cfg(feature = "rt-tokio")] + #[cfg(feature = "tokio-console")] if settingsr.logging.console.enabled { let filter = veilid_core::VeilidLayerFilter::new_no_default( veilid_core::VeilidConfigLogLevel::Trace,