Skip to main content

ferro_cli/commands/
schedule_work.rs

1//! schedule:work command - Run the scheduler daemon
2
3use console::style;
4use std::process::Command;
5
6pub fn run() {
7    println!("{} Starting scheduler daemon...", style("->").cyan());
8    println!("{}", style("Press Ctrl+C to stop").dim());
9    println!();
10
11    // Run cargo run -- schedule:work (unified binary)
12    let status = Command::new("cargo")
13        .args(["run", "--quiet", "--", "schedule:work"])
14        .status()
15        .expect("Failed to execute cargo command");
16
17    if !status.success() {
18        // Exit code might be from Ctrl+C, which is expected
19        // Only print error if it wasn't interrupted
20        if let Some(code) = status.code() {
21            if code != 130 {
22                // 130 = interrupted by Ctrl+C
23                eprintln!();
24                eprintln!(
25                    "{} Scheduler daemon exited with error (code: {})",
26                    style("Error:").red().bold(),
27                    code
28                );
29                std::process::exit(1);
30            }
31        }
32    }
33
34    println!();
35    println!("{} Scheduler daemon stopped.", style("->").cyan());
36}