Skip to main content

ForgeDaemon

Struct ForgeDaemon 

Source
pub struct ForgeDaemon<SetupOutput> { /* private fields */ }
Expand description

Main constructor to configure and launch the daemon process.

SetupOutput represents the return type of the privileged setup action. The daemonized process will return this value wrapped in a DaemonResult.

Implementations§

Source§

impl ForgeDaemon<()>

Source

pub fn new() -> Self

Creates a new default configuration.

§Defaults
  • Working directory: / (Unix) or C:\ (Windows)
  • Stdio: /dev/null
  • Umask: 0o027 (Unix)
Examples found in repository?
examples/tick_daemon.rs (line 35)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}
Source§

impl<SetupOutput> ForgeDaemon<SetupOutput>

Source

pub fn get_name(&self) -> Option<&str>

Returns the daemon name if set.

Source

pub fn pid_file_path(&self) -> Option<&Path>

Returns the configured PID file path, if any.

Source

pub fn environment(&self) -> &HashMap<String, String>

Returns a reference to the environment variables map.

Source

pub fn working_directory_path(&self) -> &Path

Returns the configured working directory.

Source

pub fn name(self, name: &str) -> Self

Sets the internal name of the daemon.

On Windows, this name is used to create a Global Mutex for single-instance locking.

Examples found in repository?
examples/tick_daemon.rs (line 36)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}
Source

pub fn pid_file<P: Into<PathBuf>>(self, path: P) -> Self

Sets the path to the PID file. This file is used for locking to ensure only one instance runs.

Examples found in repository?
examples/tick_daemon.rs (line 37)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}
Source

pub fn working_directory<P: Into<PathBuf>>(self, path: P) -> Self

Sets the working directory for the daemon.

Examples found in repository?
examples/tick_daemon.rs (line 38)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}
Source

pub fn stdin<S: Into<Stdio>>(self, stdio: S) -> Self

Configures the standard input stream.

Source

pub fn stdout<S: Into<Stdio>>(self, stdio: S) -> Self

Configures the standard output stream.

Examples found in repository?
examples/tick_daemon.rs (line 39)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}
Source

pub fn stderr<S: Into<Stdio>>(self, stdio: S) -> Self

Configures the standard error stream.

Examples found in repository?
examples/tick_daemon.rs (line 40)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}
Source

pub fn clear_env(self, clear: bool) -> Self

If true, clears all inherited environment variables for security.

Source

pub fn env(self, key: &str, value: &str) -> Self

Adds or overwrites an environment variable.

Source

pub fn env_opt(self, key: &str, value: Option<&str>) -> Self

Adds an environment variable only if value is Some.

Source

pub fn inherit_env(self) -> Self

Inherits current environment variables into the configuration.

Useful when combined with clear_env(true) to selectively keep variables, or to ensure specific variables are captured before cleaning.

Source

pub fn build(self) -> DaemonResult<Self>

Validates configuration without starting the daemon. Checks if the PID file directory exists.

Source

pub fn privileged_action<N, F>(self, action: F) -> ForgeDaemon<N>
where F: FnOnce() -> DaemonResult<N> + 'static,

Executes an action before dropping privileges (Unix) or before entering the main loop.

The action MUST return a DaemonResult. If it returns Err, the daemon will abort startup. This consumes the current builder and returns a new one with the updated generic type N.

Examples found in repository?
examples/tick_daemon.rs (lines 42-78)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}
Source

pub fn user<U: Into<User>>(self, user: U) -> Self

(Unix) Sets the user to run the daemon as (privilege dropping).

Source

pub fn group<G: Into<Group>>(self, group: G) -> Self

(Unix) Sets the group to run the daemon as.

Source

pub fn umask(self, mask: u32) -> Self

(Unix) Sets the umask for the daemon process.

Source

pub fn chroot<P: Into<PathBuf>>(self, path: P) -> Self

(Unix) Sets a chroot directory for the daemon.

Source

pub fn chown_pid_file(self, chown: bool) -> Self

(Unix) If true, changes ownership of the PID file to the target user/group.

Source

pub fn start(self) -> DaemonResult<SetupOutput>

Starts the daemonization process.

Examples found in repository?
examples/tick_daemon.rs (line 82)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    // 1. Definir rutas
13    let pwd = env::current_dir().unwrap();
14    let log_path = pwd.join("ticker.log");
15    let err_path = pwd.join("ticker.err");
16    let pid_path = pwd.join("ticker.pid");
17
18    // 2. Abrir archivos de log (Append mode)
19    let stdout_file = OpenOptions::new()
20        .create(true)
21        .append(true)
22        .open(&log_path)
23        .expect("Couldn't open stdout");
24
25    let stderr_file = OpenOptions::new()
26        .create(true)
27        .append(true)
28        .open(&err_path)
29        .expect("Couldn't open stderr");
30
31    println!("Launching a simple ticker Daemon...");
32    println!("Logs will be written to: {:?}", log_path);
33
34    // 3. Configurar el Daemon
35    let daemon = ForgeDaemon::new()
36        .name("tick_daemon")
37        .pid_file(&pid_path)
38        .working_directory(&pwd)
39        .stdout(stdout_file)
40        .stderr(stderr_file)
41        // AQUÍ está el cambio principal: Pasamos la lógica como un closure
42        .privileged_action(move || {
43            
44            // --- INICIO CÓDIGO DEL DAEMON ---
45            
46            // A. Configurar manejo de señales para parada limpia (SIGTERM / SIGINT)
47            let term = Arc::new(AtomicBool::new(false));
48            flag::register(SIGTERM, Arc::clone(&term))?; // Systemd Stop
49            flag::register(SIGINT, Arc::clone(&term))?;  // Ctrl+C (Manual)
50
51            println!("[Ticker] Servicio iniciado. PID: {}", std::process::id());
52
53            let frases = [
54                "Estan vivos",
55                "I have no mouth",
56                "I must scream",
57                "Hello world",
58                "Adios mundo :0"
59            ];
60
61            let mut i = 0;
62
63            // B. Bucle principal que respeta la señal de parada
64            while !term.load(Ordering::Relaxed) {
65                let frase = frases[i % frases.len()];
66                
67                // C. Usamos println!: La librería ya redirigió esto al archivo .log
68                println!("[Ticker] Ping #{} - {}", i, frase);
69                
70                i += 1;
71                
72                // Dormir en intervalos cortos para revisar la señal de parada frecuentemente
73                thread::sleep(Duration::from_secs(3));
74            }
75
76            println!("[Ticker] Señal de parada recibida. Cerrando limpiamente.");
77            Ok(())
78        });
79
80    // 4. Arrancar usando la lógica refactorizada (Systemd o Fork)
81    // Nota: Usamos la función del módulo unix directamente
82    daemon_forge::ForgeDaemon::start(daemon)?;
83
84    Ok(())
85}

Trait Implementations§

Source§

impl<T> Debug for ForgeDaemon<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ForgeDaemon<()>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<SetupOutput> Freeze for ForgeDaemon<SetupOutput>

§

impl<SetupOutput> !RefUnwindSafe for ForgeDaemon<SetupOutput>

§

impl<SetupOutput> !Send for ForgeDaemon<SetupOutput>

§

impl<SetupOutput> !Sync for ForgeDaemon<SetupOutput>

§

impl<SetupOutput> Unpin for ForgeDaemon<SetupOutput>

§

impl<SetupOutput> !UnwindSafe for ForgeDaemon<SetupOutput>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.