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) = @_;
code => sub {
my ($param) = @_;
- $self->start($param->{debug});
+ if (&$init_ppid()) {
+ $self->start($param->{debug});
+ } else {
+ PVE::Tools::run_command(['systemctl', 'start', $self->{name}]);
+ }
return undef;
}});
code => sub {
my ($param) = @_;
- &$reload_daemon($self, $use_hup);
+ if (&$init_ppid()) {
+ &$reload_daemon($self, $use_hup);
+ } else {
+ PVE::Tools::run_command(['systemctl', $use_hup ? 'reload-or-restart' : 'restart', $self->{name}]);
+ }
return undef;
}});
code => sub {
my ($param) = @_;
- $self->stop();
+ if (&$init_ppid()) {
+ $self->stop();
+ } else {
+ PVE::Tools::run_command(['systemctl', 'stop', $self->{name}]);
+ }
return undef;
}});