diff --git a/debian/control b/debian/control index f9d8e1db..9fe57525 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,7 @@ Maintainer: Proxmox Support Team Build-Depends: bash-completion, debhelper (>= 10), libpam0g-dev, + libsystemd-dev, libzstd-dev (>= 1.3.8), pkg-config, python3-docutils, diff --git a/etc/proxmox-backup-proxy.service.in b/etc/proxmox-backup-proxy.service.in index 7d91b687..5f5fdbda 100644 --- a/etc/proxmox-backup-proxy.service.in +++ b/etc/proxmox-backup-proxy.service.in @@ -5,8 +5,9 @@ After=network.target Requires=proxmox-backup.service [Service] -Type=simple +Type=notify ExecStart=%LIBEXECDIR%/proxmox-backup/proxmox-backup-proxy +ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure User=%PROXY_USER% Group=%PROXY_USER% diff --git a/etc/proxmox-backup.service.in b/etc/proxmox-backup.service.in index 9d651dd3..a843abd5 100644 --- a/etc/proxmox-backup.service.in +++ b/etc/proxmox-backup.service.in @@ -4,8 +4,9 @@ Wants=network-online.target After=network.target [Service] -Type=simple +Type=notify ExecStart=%LIBEXECDIR%/proxmox-backup/proxmox-backup-api +ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure [Install] diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs index a9a71f3e..2bba229e 100644 --- a/src/bin/proxmox-backup-api.rs +++ b/src/bin/proxmox-backup-api.rs @@ -67,6 +67,8 @@ fn run() -> Result<(), Error> { }, )?; + daemon::systemd_notify(daemon::SystemdNotify::Ready)?; + tokio::run(lazy(|| { let init_result: Result<(), Error> = try_block!({ diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 60f663ca..46d62194 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -100,6 +100,8 @@ fn run() -> Result<(), Error> { }, )?; + daemon::systemd_notify(daemon::SystemdNotify::Ready)?; + tokio::run(lazy(|| { let init_result: Result<(), Error> = try_block!({ diff --git a/src/tools/daemon.rs b/src/tools/daemon.rs index 870e5610..9dc3dc8e 100644 --- a/src/tools/daemon.rs +++ b/src/tools/daemon.rs @@ -103,6 +103,9 @@ impl Reloader { } Ok(ForkResult::Parent { child }) => { eprintln!("forked off a new server (pid: {})", child); + if let Err(e) = systemd_notify(SystemdNotify::MainPid(child)) { + log::error!("failed to notify systemd about the new main pid: {}", e); + } Ok(()) } Err(e) => { @@ -178,8 +181,12 @@ where crate::tools::request_shutdown(); // make sure we are in shutdown mode if server::is_reload_request() { log::info!("daemon reload..."); + if let Err(e) = systemd_notify(SystemdNotify::Reloading) { + log::error!("failed to notify systemd about the state change: {}", e); + } if let Err(e) = reloader.take().unwrap().fork_restart() { log::error!("error during reload: {}", e); + let _ = systemd_notify(SystemdNotify::Status(format!("error during reload"))); } } else { log::info!("daemon shutting down...");