Author: arkurth Date: Fri Mar 5 16:08:55 2010 New Revision: 919463 URL: http://svn.apache.org/viewvc?rev=919463&view=rev Log: VCL-127 Moved call to preplogfile() to the beginning and moved call to rename_vcld_process() to after daemonize(). rename_vcld_process() contains calls to notify() and STDOUT should be redirected by daemonize() before it is called.
Modified: incubator/vcl/trunk/managementnode/bin/vcld Modified: incubator/vcl/trunk/managementnode/bin/vcld URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/bin/vcld?rev=919463&r1=919462&r2=919463&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/bin/vcld (original) +++ incubator/vcl/trunk/managementnode/bin/vcld Fri Mar 5 16:08:55 2010 @@ -64,8 +64,7 @@ # Turn on autoflush $| = 1; -# Rename this process -rename_vcld_process(); +preplogfile(); # Check if -setup argument was specified if ($SETUP_MODE) { @@ -77,6 +76,9 @@ &daemonize; } +# Rename this process +rename_vcld_process(); + # Variables to store child process information our %child_pids = (); # keys are current child process IDs our $child_count = 0; # current number of children @@ -106,8 +108,6 @@ =cut sub main () { - preplogfile($LOGFILE); - #=========================================================================== # BEGIN NEW CODE # This section does some prep work before looping @@ -116,7 +116,7 @@ # Set the vcld environment variable to 0 so other subroutines know if this is the vcld or child process $ENV{vcld} = 1; notify($ERRORS{'DEBUG'}, $LOGFILE, "vcld environment variable set to $ENV{vcld} for this process"); - + # Create a hash to store all of the program state information my %info; @@ -129,7 +129,7 @@ notify($ERRORS{'CRITICAL'}, $LOGFILE, "unable to retrieve management node information from database"); exit; } - + # Define local variables from the management node hash for code simplicity my $management_node_id = $info{managementnode}{id}; my $management_node_hostname = $info{managementnode}{hostname}; @@ -137,7 +137,7 @@ # Set environment variables for global management node information $ENV{management_node_id} = $management_node_id; notify($ERRORS{'DEBUG'}, $LOGFILE, "management_node_id environment variable set: $management_node_id"); - + # Get the management node checkin interval from the database if defined # Otherwise, the default is 12 seconds my $management_node_checkin_interval = 12; @@ -146,17 +146,17 @@ } notify($ERRORS{'DEBUG'}, $LOGFILE, "management node checkin interval is $management_node_checkin_interval seconds"); notify($ERRORS{'OK'}, $LOGFILE, "vcld started on $management_node_hostname"); - + #=========================================================================== while (1) { SLEEP: - + delete $ENV{request_id}; delete $ENV{reservation_id}; delete $ENV{state}; sleep $management_node_checkin_interval; - + #=========================================================================== # Update lastcheckin for this management node my $lastcheckin_timestamp = update_lastcheckin($management_node_id); @@ -774,12 +774,7 @@ chdir '/' or die "Can't chdir to /: $!"; defined(my $pid = fork) or die "Can't fork $!"; exit if $pid; - #development - #$0 = "vcldev"; - #production - #$0 = "vcld"; - #$0 = $PROCESSNAME; - print "Created process $$ \"$0\"\n"; + print "Created VCL daemon process: $$\n"; setsid or die "Can't start a new session: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null $!"; open STDOUT, ">>$LOGFILE" or die "Can't write $LOGFILE $!"; @@ -855,7 +850,7 @@ if ($module_object->can('setup')) { notify($ERRORS{'DEBUG'}, 0, "setup subroutine has been implemented by '$module_name'"); - print "----------------------------------------------------------------------\n"; + print "----------------------------------------------------------------------------\n"; print "Beginning setup for '$module_name' module...\n\n"; # Call the setup subroutine and check it's return value @@ -873,7 +868,7 @@ } } - print "======================================================================\n"; + print "============================================================================\n"; exit; } ## end sub help