mirror of
https://github.com/telemt/telemt.git
synced 2026-06-18 08:58:30 +03:00
Add daemon lifecycle subcommands: start, stop, reload, status
Implement CLI subcommands for managing telemt as a daemon: - `start [config.toml]` - Start as background daemon (implies --daemon) - `stop` - Stop running daemon by sending SIGTERM - `reload` - Reload configuration by sending SIGHUP - `status` - Check if daemon is running via PID file Subcommands use the PID file (default /var/run/telemt.pid) to locate the running daemon. Stop command waits up to 10 seconds for graceful shutdown. Status cleans up stale PID files automatically. Updated help text with subcommand documentation and usage examples. Exit codes follow Unix convention: 0 for success, 1 for not running or error. Signed-off-by: Vladimir Krivopalov <argenet@yandex.ru>
This commit is contained in:
committed by
Vladimir Krivopalov
parent
39875afbff
commit
dc2b4395bd
11
src/main.rs
11
src/main.rs
@@ -30,11 +30,18 @@ mod transport;
|
||||
mod util;
|
||||
|
||||
fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let cmd = cli::parse_command(&args);
|
||||
|
||||
// Handle subcommands that don't need the server (stop, reload, status, init)
|
||||
if let Some(exit_code) = cli::execute_subcommand(&cmd) {
|
||||
std::process::exit(exit_code);
|
||||
}
|
||||
|
||||
// On Unix, handle daemonization before starting tokio runtime
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let daemon_opts = cli::parse_daemon_args(&args);
|
||||
let daemon_opts = cmd.daemon_opts;
|
||||
|
||||
// Daemonize if requested (must happen before tokio runtime starts)
|
||||
if daemon_opts.should_daemonize() {
|
||||
|
||||
Reference in New Issue
Block a user