[pve-devel] [PATCH] Revert "PVE:Daemon start/restart with systemd"

Emmanuel Kasper e.kasper at proxmox.com
Tue Apr 26 15:47:33 CEST 2016


This reverts commit a526ab1cfc6adda11dd4830501b1eb8a14b2bf6d.

This commit has two problems:
 * it breaks starting in debug mode, as calling systemctl
 do not pass the -debug flag
 * it has strange default, as no unix daemon would start/
 stop itself calling the init system in the background

 Reverting this patch do not change the way the services
 are started / stopped / reloaded via the API as API calls
 translate to PVE::Tools::run_command(['systemctl', $cmd, $service]);
 in Services.pm
---
 src/PVE/Daemon.pm | 28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/PVE/Daemon.pm b/src/PVE/Daemon.pm
index f81e589..6b58d22 100644
--- a/src/PVE/Daemon.pm
+++ b/src/PVE/Daemon.pm
@@ -583,16 +583,6 @@ my $read_pid = sub {
     return $pid;
 };
 
-# checks if the process was started by systemd
-my $init_ppid = sub {
-
-    if (getppid() == 1) {
-       return 1;
-    } else {
-       return 0;
-    }
-}; 
-
 sub running {
     my ($self) = @_;
 
@@ -669,11 +659,7 @@ sub register_start_command {
 	code => sub {
 	    my ($param) = @_;
 
-            if (&$init_ppid()) {
-                $self->start($param->{debug});
-            } else {
-                PVE::Tools::run_command(['systemctl', 'start', $self->{name}]);
-            }
+	    $self->start($param->{debug});
 
 	    return undef;
 	}});  
@@ -719,11 +705,7 @@ sub register_restart_command {
 	code => sub {
 	    my ($param) = @_;
 
-	    if (&$init_ppid()) {
-		&$reload_daemon($self, $use_hup);
-	    } else {
-		PVE::Tools::run_command(['systemctl', $use_hup ? 'reload-or-restart' : 'restart', $self->{name}]);
-	    }
+	    &$reload_daemon($self, $use_hup);
 
 	    return undef;
 	}});		   
@@ -773,11 +755,7 @@ sub register_stop_command {
 	code => sub {
 	    my ($param) = @_;
 	    
-	    if (&$init_ppid()) {
-		$self->stop();
-	    } else {
-		PVE::Tools::run_command(['systemctl', 'stop', $self->{name}]);
-	    }
+	    $self->stop();
 
 	    return undef;
 	}});		   
-- 
2.1.4





More information about the pve-devel mailing list