/[pxelator]/lib/PXElator/daemons.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/daemons.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 231 by dpavlin, Sun Aug 16 22:24:22 2009 UTC revision 321 by dpavlin, Fri Aug 28 16:20:43 2009 UTC
# Line 32  sub audit { Line 32  sub audit {
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;
# Line 54  sub start_stop { Line 56  sub start_stop {
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 );

Legend:
Removed from v.231  
changed lines
  Added in v.321

  ViewVC Help
Powered by ViewVC 1.1.26