]> git.proxmox.com Git - proxmox-backup.git/commitdiff
use service Type=notify
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 25 Apr 2019 08:38:26 +0000 (08:38 +0000)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 25 Apr 2019 11:01:33 +0000 (11:01 +0000)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
debian/control
etc/proxmox-backup-proxy.service.in
etc/proxmox-backup.service.in
src/bin/proxmox-backup-api.rs
src/bin/proxmox-backup-proxy.rs
src/tools/daemon.rs

index f9d8e1db8d6621b49ee34e8a4421d89e981d1a99..9fe57525f85b30bd4fc18b35425ee15dfd51c6b2 100644 (file)
@@ -5,6 +5,7 @@ Maintainer: Proxmox Support Team <support@proxmox.com>
 Build-Depends: bash-completion,
                debhelper (>= 10),
                libpam0g-dev,
+               libsystemd-dev,
                libzstd-dev (>= 1.3.8),
                pkg-config,
                python3-docutils,
index 7d91b6871b24544919fb4eb69637137aec81aa0a..5f5fdbda3fa15d1b8d64232f1b4cf89e50fe8221 100644 (file)
@@ -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%
index 9d651dd3cafb5f57b4b003c85dfb83d790e8510f..a843abd504cf8f0107e8bfcf6114ff193e347aba 100644 (file)
@@ -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]
index a9a71f3e12825e6b7661314aac4d199398274643..2bba229e346928e989bc74a7e46ce6e46fba8d72 100644 (file)
@@ -67,6 +67,8 @@ fn run() -> Result<(), Error> {
         },
     )?;
 
+    daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
+
     tokio::run(lazy(||  {
 
         let init_result: Result<(), Error> = try_block!({
index 60f663caaf106018a2c2dcc80669f6f8745e5d00..46d621946d2645c9344fb0f8a2b0d3f2a4509c86 100644 (file)
@@ -100,6 +100,8 @@ fn run() -> Result<(), Error> {
         },
     )?;
 
+    daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
+
     tokio::run(lazy(||  {
 
         let init_result: Result<(), Error> = try_block!({
index 870e561080266e2c6b3a361347b1f0fcd8c418f9..9dc3dc8e663cd75d3066892b9d944941aa9e5aa3 100644 (file)
@@ -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...");