From c0b7181ddc1b876c92cf497d4668b72d2711d5d2 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Fri, 17 May 2024 13:32:43 -0300 Subject: [PATCH] Allow for both startup options to be None --- magic-nix-cache/src/main.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/magic-nix-cache/src/main.rs b/magic-nix-cache/src/main.rs index c9c8c0a..39386ae 100644 --- a/magic-nix-cache/src/main.rs +++ b/magic-nix-cache/src/main.rs @@ -133,12 +133,6 @@ impl Args { ))); } - if self.startup_notification_url.is_none() && self.startup_notification_file.is_none() { - return Err(error::Error::Config(String::from( - "you must specify either --startup-notification-url or --startup-notification-file", - ))); - } - Ok(()) } } @@ -405,12 +399,14 @@ async fn main_cli() -> Result<()> { } } - // Notify of startup via file + // Notify of startup by writing "1" to the specified file if let Some(startup_notification_file_path) = args.startup_notification_file { + let file_contents: &[u8] = b"1"; + tracing::debug!("Startup notification via file at {startup_notification_file_path:?}"); let mut notification_file = File::create(&startup_notification_file_path).await?; - notification_file.write_all(b"1").await?; + notification_file.write_all(file_contents).await?; tracing::debug!("Created startup notification file at {startup_notification_file_path:?}"); }