--- lib/PXElator/daemons.pm 2009/08/12 23:59:01 208 +++ lib/PXElator/daemons.pm 2009/08/17 15:14:58 245 @@ -10,7 +10,11 @@ use CouchDB; our $pids; -$pids = { httpd => $$, kvm => 'not started' } unless defined $pids; # keep pids on refresh +$pids = { + httpd => $$, + kvm => 'not started', + wireshark => 'not started', +} unless defined $pids; # keep pids on refresh sub DESTROY { warn "pids ",dump( $pids ); @@ -32,7 +36,9 @@ my $daemon = shift; my $pid = $pids->{$daemon}; - my $pid_path = "$server::conf/$daemon.pid"; + my $pid_path = "$daemon.pid"; + $pid_path =~ s{/}{-}g; + $pid_path = "$server::conf/$pid_path"; if ( ! $pid && -e $pid_path ) { my $p = read_file $pid_path; @@ -48,11 +54,18 @@ $pid ||= 'not started'; warn "start_stop $daemon $pid\n"; - if ( $pid =~ m{^\d+$} ) { + if ( $pid =~ m{^\d+$} && kill 0, $pid ) { my $pstree = `pstree -p $pid`; my @pids = $pstree =~ m{\((\d+)\)}g; warn "pstree $pstree pids ",dump( @pids ); - kill 1, $_ foreach reverse @pids; + foreach ( @pids ) { + warn "kill $_\n"; + kill 1, $_; + if ( kill 0, $_ ) { + warn "kill 9 $_"; + kill 9, $_; + } + } $pids->{$daemon} = 'stopped'; audit 'stopped', $daemon, pid => $pid; return qq|$daemon pid $pid stopped|; @@ -67,7 +80,7 @@ # child my $invoke = 'start'; $invoke = $1 if $daemon =~ s{/(.+)}{}; - if ( $daemon =~ m{dhcpd|tftpd|dnsd} ) { + if ( $daemon =~ m{dhcpd|tftpd|dnsd|syslogd} ) { my $exec = "perl -I$server::base_dir/lib -I$server::base_dir/lib/PXElator -M$daemon -e ${daemon}::${invoke}"; audit 'exec', $daemon, 'exec' => $exec; x11::xterm( $daemon => $exec );