diff --git a/src/agent/src/main.rs b/src/agent/src/main.rs index fa1b3181fa..a2014bde5e 100644 --- a/src/agent/src/main.rs +++ b/src/agent/src/main.rs @@ -83,14 +83,21 @@ fn announce(logger: &Logger) { Ok(s) => s, Err(_) => String::from(""), }; + info!(logger, "announce"; "agent-commit" => commit.as_str(), + + // Avoid any possibility of confusion with the old agent + "agent-type" => "rust", + "agent-version" => version::AGENT_VERSION, "api-version" => version::API_VERSION, ); } fn main() -> Result<()> { + let args: Vec = env::args().collect(); + env::set_var("RUST_BACKTRACE", "full"); lazy_static::initialize(&SHELLS); @@ -106,6 +113,13 @@ fn main() -> Result<()> { announce(&logger); + if args.len() == 2 && args[1] == "--version" { + // force logger to flush + drop(logger); + + exit(0); + } + // This "unused" variable is required as it enables the global (and crucially static) logger, // which is required to satisfy the the lifetime constraints of the auto-generated gRPC code. let _guard = slog_scope::set_global_logger(logger.new(o!("subsystem" => "grpc"))); @@ -306,7 +320,7 @@ use nix::fcntl::{self, OFlag}; use nix::sys::stat::Mode; use std::os::unix::io::{FromRawFd, RawFd}; use std::path::PathBuf; -use std::process::{Command, Stdio}; +use std::process::{exit, Command, Stdio}; fn setup_debug_console(shells: Vec) -> Result<()> { for shell in shells.iter() {