Skip to content

Commit

Permalink
clusterd: Fix restart
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed Jan 27, 2025
1 parent 9da937f commit adc5996
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions clusterd/clusterd
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit adc5996

Please sign in to comment.