From: Atif G. <ma...@us...> - 2001-06-19 12:37:09
|
Update of /cvsroot/ispman/ispman-utils/bin In directory usw-pr-cvs1:/tmp/cvs-serv4983/bin Modified Files: ispman-agent Log Message: ispman-agent should now always write logs to install-dir/var/machine-name.ispman-agent.log no more $VAR=undef in the logs Index: ispman-agent =================================================================== RCS file: /cvsroot/ispman/ispman-utils/bin/ispman-agent,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** ispman-agent 2001/04/29 02:39:30 1.20 --- ispman-agent 2001/06/19 12:37:06 1.21 *************** *** 10,14 **** use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK ! $name $hostname $hostnames $ispman $pid_file $domains ); --- 10,14 ---- use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK ! $name $hostname $hostnames $ispman $pid_file $log_file $domains ); *************** *** 48,51 **** --- 48,52 ---- $pid_file=join "/", ($ispman->getConf("installDir"), "var/$hostname.ispman-agent.pid"); + $log_file=join "/", ($ispman->getConf("installDir"), "var/$hostname.ispman-agent.log"); *************** *** 84,92 **** ! ! sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; ! open STDOUT, '>>/tmp/ispman.log' or die "Can't write to /tmp/ispman.log: $!"; defined(my $pid = fork) or die "Can't fork: $!"; if ($pid) { --- 85,99 ---- ! sub open_log { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; ! open STDOUT, ">> $log_file " or die "Can't write to $log_file: $!"; ! open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; ! } ! ! ! ! sub daemonize { ! open_log; defined(my $pid = fork) or die "Can't fork: $!"; if ($pid) { *************** *** 96,108 **** print "Process forked. "; print "pid is $pid\nUsing pidfile $pid_file\n"; exit 0; # I am the parent } - setsid or die "Can't start a new session: $!"; - open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; } ! unless ($ARGV[0] eq "nodetach"){ ! daemonize(); } --- 103,116 ---- print "Process forked. "; print "pid is $pid\nUsing pidfile $pid_file\n"; + setsid or die "Can't start a new session: $!"; exit 0; # I am the parent } } ! if ($ARGV[0] eq "nodetach"){ ! open_log(); ! } else { ! daemonize(); } *************** *** 128,132 **** } ! print Dumper($processHash); for $domain (keys %$processHash){ --- 136,140 ---- } ! print Dumper($processHash) if $processHash; for $domain (keys %$processHash){ |