diff --git a/src/main.rs b/src/main.rs index 0486f1c..0d3e113 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,8 +36,6 @@ struct Args { enum Command { /// Run as a background daemon providing a web UI. Daemon, - /// Stop the running daemon process. - Kill, } /// Default config content, embedded in the binary. @@ -93,65 +91,24 @@ async fn main() { let log_buffer = logger::setup_logger(); let args = Args::parse(); - if let Some(command) = &args.command { - match command { - Command::Daemon => { - log::info!("🚀 Starting daemon..."); + if let Some(Command::Daemon) = &args.command { + log::info!("🚀 Starting daemon..."); - // Create files for stdout and stderr in the current directory - let stdout = - fs::File::create("daemon.out").expect("Could not create daemon.out"); - let stderr = - fs::File::create("daemon.err").expect("Could not create daemon.err"); + // Create files for stdout and stderr in the current directory + let stdout = fs::File::create("daemon.out").expect("Could not create daemon.out"); + let stderr = fs::File::create("daemon.err").expect("Could not create daemon.err"); - let daemonize = Daemonize::new() - .pid_file("ntp_timeturner.pid") // Create a PID file - .working_directory(".") // Keep the same working directory - .stdout(stdout) - .stderr(stderr); + let daemonize = Daemonize::new() + .pid_file("ntp_timeturner.pid") // Create a PID file + .working_directory(".") // Keep the same working directory + .stdout(stdout) + .stderr(stderr); - match daemonize.start() { - Ok(_) => { /* Process is now daemonized */ } - Err(e) => { - log::error!("Error daemonizing: {}", e); - return; // Exit if daemonization fails - } - } - } - Command::Kill => { - log::info!("🛑 Stopping daemon..."); - let pid_file = "ntp_timeturner.pid"; - match fs::read_to_string(pid_file) { - Ok(pid_str) => { - let pid_str = pid_str.trim(); - log::info!("Found daemon with PID: {}", pid_str); - match std::process::Command::new("kill").arg("-9").arg(format!("-{}", pid_str)).status() { - Ok(status) => { - if status.success() { - log::info!("✅ Daemon stopped successfully."); - if fs::remove_file(pid_file).is_err() { - log::warn!("Could not remove PID file '{}'. It may need to be removed manually.", pid_file); - } - } else { - log::error!("'kill' command failed with status: {}. The daemon may not be running, or you may not have permission to stop it.", status); - log::warn!("Attempting to remove stale PID file '{}'...", pid_file); - if fs::remove_file(pid_file).is_ok() { - log::info!("Removed stale PID file."); - } else { - log::warn!("Could not remove PID file."); - } - } - } - Err(e) => { - log::error!("Failed to execute 'kill' command. Is 'kill' in your PATH? Error: {}", e); - } - } - } - Err(_) => { - log::error!("Could not read PID file '{}'. Is the daemon running in this directory?", pid_file); - } - } - return; + match daemonize.start() { + Ok(_) => { /* Process is now daemonized */ } + Err(e) => { + log::error!("Error daemonizing: {}", e); + return; // Exit if daemonization fails } } } @@ -248,9 +205,7 @@ async fn main() { let state = sync_state.lock().unwrap(); let config = sync_config.lock().unwrap(); - if config.is_auto_sync_paused() { - log::info!("Auto-sync is temporarily paused."); - } else if config.auto_sync_enabled && state.latest.is_some() { + if config.auto_sync_enabled && state.latest.is_some() { let delta = state.get_ewma_clock_delta(); let frame = state.latest.as_ref().unwrap(); diff --git a/src/system.rs b/src/system.rs index 77a1aa0..64205b4 100644 --- a/src/system.rs +++ b/src/system.rs @@ -45,13 +45,21 @@ pub fn calculate_target_time(frame: &LtcFrame, config: &Config) -> DateTime Result<(), ()> { pub fn set_date(date: &str) -> Result<(), ()> { #[cfg(target_os = "linux")] { - let datetime_str = format!("{} 10:00:00", date); let success = Command::new("sudo") .arg("date") .arg("--set") - .arg(&datetime_str) + .arg(date) .status() .map(|s| s.success()) .unwrap_or(false); if success { - log::info!("Set system date and time to {}", datetime_str); + log::info!("Set system date to {}", date); Ok(()) } else { - log::error!("Failed to set system date and time"); + log::error!("Failed to set system date"); Err(()) } } diff --git a/static/assets/FuturaStdHeavy.otf b/static/assets/FuturaStdHeavy.otf deleted file mode 100644 index 7b8c22d..0000000 Binary files a/static/assets/FuturaStdHeavy.otf and /dev/null differ diff --git a/static/assets/quartz-ms-regular.ttf b/static/assets/quartz-ms-regular.ttf deleted file mode 100644 index 15c7ce4..0000000 Binary files a/static/assets/quartz-ms-regular.ttf and /dev/null differ diff --git a/static/assets/timeturner_controls.png b/static/assets/timeturner_controls.png deleted file mode 100644 index a91f39b..0000000 Binary files a/static/assets/timeturner_controls.png and /dev/null differ diff --git a/static/assets/timeturner_delta_green.png b/static/assets/timeturner_delta_green.png deleted file mode 100644 index ddc84b9..0000000 Binary files a/static/assets/timeturner_delta_green.png and /dev/null differ diff --git a/static/assets/timeturner_delta_orange.png b/static/assets/timeturner_delta_orange.png deleted file mode 100644 index 64e9776..0000000 Binary files a/static/assets/timeturner_delta_orange.png and /dev/null differ diff --git a/static/assets/timeturner_delta_red.png b/static/assets/timeturner_delta_red.png deleted file mode 100644 index c7272ac..0000000 Binary files a/static/assets/timeturner_delta_red.png and /dev/null differ diff --git a/static/assets/timeturner_jitter_green.png b/static/assets/timeturner_jitter_green.png deleted file mode 100644 index 8cc64e3..0000000 Binary files a/static/assets/timeturner_jitter_green.png and /dev/null differ diff --git a/static/assets/timeturner_jitter_orange.png b/static/assets/timeturner_jitter_orange.png deleted file mode 100644 index 96c5f84..0000000 Binary files a/static/assets/timeturner_jitter_orange.png and /dev/null differ diff --git a/static/assets/timeturner_jitter_red.png b/static/assets/timeturner_jitter_red.png deleted file mode 100644 index 8813159..0000000 Binary files a/static/assets/timeturner_jitter_red.png and /dev/null differ diff --git a/static/assets/timeturner_logs.png b/static/assets/timeturner_logs.png deleted file mode 100644 index 6bdd935..0000000 Binary files a/static/assets/timeturner_logs.png and /dev/null differ diff --git a/static/assets/timeturner_ltc_green.png b/static/assets/timeturner_ltc_green.png deleted file mode 100644 index 4329913..0000000 Binary files a/static/assets/timeturner_ltc_green.png and /dev/null differ diff --git a/static/assets/timeturner_ltc_orange.png b/static/assets/timeturner_ltc_orange.png deleted file mode 100644 index b060ac2..0000000 Binary files a/static/assets/timeturner_ltc_orange.png and /dev/null differ diff --git a/static/assets/timeturner_ltc_red.png b/static/assets/timeturner_ltc_red.png deleted file mode 100644 index a8e7f96..0000000 Binary files a/static/assets/timeturner_ltc_red.png and /dev/null differ diff --git a/static/assets/timeturner_network.png b/static/assets/timeturner_network.png deleted file mode 100644 index 06ec4b9..0000000 Binary files a/static/assets/timeturner_network.png and /dev/null differ diff --git a/static/assets/timeturner_ntp_green.png b/static/assets/timeturner_ntp_green.png deleted file mode 100644 index caf824d..0000000 Binary files a/static/assets/timeturner_ntp_green.png and /dev/null differ diff --git a/static/assets/timeturner_ntp_orange.png b/static/assets/timeturner_ntp_orange.png deleted file mode 100644 index 88319b5..0000000 Binary files a/static/assets/timeturner_ntp_orange.png and /dev/null differ diff --git a/static/assets/timeturner_ntp_red.png b/static/assets/timeturner_ntp_red.png deleted file mode 100644 index 16e66ee..0000000 Binary files a/static/assets/timeturner_ntp_red.png and /dev/null differ diff --git a/static/assets/timeturner_sync_green.png b/static/assets/timeturner_sync_green.png deleted file mode 100644 index 9b4988e..0000000 Binary files a/static/assets/timeturner_sync_green.png and /dev/null differ diff --git a/static/assets/timeturner_sync_orange.png b/static/assets/timeturner_sync_orange.png deleted file mode 100644 index 0b41130..0000000 Binary files a/static/assets/timeturner_sync_orange.png and /dev/null differ diff --git a/static/assets/timeturner_sync_red.png b/static/assets/timeturner_sync_red.png deleted file mode 100644 index 1c4c4c9..0000000 Binary files a/static/assets/timeturner_sync_red.png and /dev/null differ