/[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 227 by dpavlin, Sun Aug 16 21:27:15 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 );
# Line 80  sub start_stop { Line 82  sub start_stop {
82                          # child                          # child
83                          my $invoke = 'start';                          my $invoke = 'start';
84                          $invoke = $1 if $daemon =~ s{/(.+)}{};                          $invoke = $1 if $daemon =~ s{/(.+)}{};
85                          if ( $daemon =~ m{dhcpd|tftpd|dnsd} ) {                          if ( $daemon =~ m{dhcpd|tftpd|dnsd|syslogd} ) {
86                                  my $exec = "perl -I$server::base_dir/lib -I$server::base_dir/lib/PXElator -M$daemon -e ${daemon}::${invoke}";                                  my $exec = "perl -I$server::base_dir/lib -I$server::base_dir/lib/PXElator -M$daemon -e ${daemon}::${invoke}";
87                                  audit 'exec', $daemon, 'exec' => $exec;                                  audit 'exec', $daemon, 'exec' => $exec;
88                                  x11::xterm( $daemon => $exec );                                  x11::xterm( $daemon => $exec );

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

  ViewVC Help
Powered by ViewVC 1.1.26