32 |
CouchDB::audit( $msg, $daemon, { daemon => $daemon, message => $msg, @_ } ); |
CouchDB::audit( $msg, $daemon, { daemon => $daemon, message => $msg, @_ } ); |
33 |
} |
} |
34 |
|
|
35 |
|
mkdir "$server::conf/pid" unless -d "$server::conf/pid"; |
36 |
|
|
37 |
sub start_stop { |
sub start_stop { |
38 |
my $daemon = shift; |
my $daemon = shift; |
39 |
|
|
40 |
my $pid = $pids->{$daemon}; |
my $pid = $pids->{$daemon}; |
41 |
my $pid_path = "$daemon.pid"; |
my $pid_path = $daemon; |
42 |
$pid_path =~ s{/}{-}g; |
$pid_path =~ s{/}{-}g; |
43 |
$pid_path = "$server::conf/$pid_path"; |
$pid_path = "$server::conf/pid/$pid_path"; |
44 |
|
|
45 |
if ( ! $pid && -e $pid_path ) { |
if ( ! $pid && -e $pid_path ) { |
46 |
my $p = read_file $pid_path; |
my $p = read_file $pid_path; |
56 |
$pid ||= 'not started'; |
$pid ||= 'not started'; |
57 |
warn "start_stop $daemon $pid\n"; |
warn "start_stop $daemon $pid\n"; |
58 |
|
|
59 |
if ( $pid =~ m{^\d+$} ) { |
if ( $pid =~ m{^\d+$} && kill 0, $pid ) { |
60 |
my $pstree = `pstree -p $pid`; |
my $pstree = `pstree -p $pid`; |
61 |
my @pids = $pstree =~ m{\((\d+)\)}g; |
my @pids = $pstree =~ m{\((\d+)\)}g; |
62 |
warn "pstree $pstree pids ",dump( @pids ); |
warn "pstree $pstree pids ",dump( @pids ); |