From adc5996933e9cda7f37f5ad8bba0d15d57181d57 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 27 Jan 2025 20:56:39 +0100 Subject: [PATCH] clusterd: Fix restart Currently restart isn't working, because we removed 'kill' from the options and udp_rx_restart is using it. Just exit instead, the service manage should restart the service. --- clusterd/clusterd | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/clusterd/clusterd b/clusterd/clusterd index 17e13fa..afcb828 100755 --- a/clusterd/clusterd +++ b/clusterd/clusterd @@ -68,28 +68,6 @@ sub decode { return @$msg; } -sub kill_previous_server { # kill_previous_server('clusterd') - my ($command)=@_; - my $ret=0; - - # quickfix - dont kill our parent which might be the init.d/script with the same name.... - - my $ppid; - for (`ps -o ppid,comm -p $$`) { - $ppid=$1 if /(\d+)/; - } - - for (`ps -Ao pid,comm`) { - my @F=split; - if ($F[1] eq $command && $F[0] ne $$ && $F[0] ne $ppid) { - kill 1=>$F[0]; - warn "stopped $command pid $F[0]\n"; - $ret=1; - } - } - return $ret; -} - #------------------------------------- package main; @@ -1244,15 +1222,10 @@ sub log_to_stat_target { # ---------------------------------------------------------- sub udp_rx_restart { - # double-fork, because kill_previous_server() won't kill its parent - my $pid=fork; - if (defined $pid && $pid==0) { - my $pid2=fork; - if (defined $pid2 && $pid==0) { - exec '/usr/sbin/clusterd','--kill','--daemon'; - die "exec failed: $!\n"; - } - } + # just exit and leave the restart to the service manager + # exist status 40 can be used with RestartForceExitStatus= + warn "received restart request. Exiting with status 40\n"; + exit 40; } sub udp_rx_flush_gidcache { @@ -2219,8 +2192,6 @@ if (defined $options{'push'}) { My::Select::run(); } elsif ($options{'lsof'}) { lsof($options{'lsof'}); -} elsif ($options{'kill'}) { - Donald::Tools::kill_previous_server('clusterd'); } else { @ARGV or die USAGE; my ($cmd,@args)=@ARGV;