Parent Directory
|
Revision Log
Close stdin/stdtuo before starting services.
# # This script is invoked after a lightweight code update has completed. # # It is used to kick the services scripts if they are running so that # they pick up any new code. # # In addition, I anticipate this being the place to hook any per-module functionality # that might need a post-lwc step. The scheme would probably be a module writes # a file into FIG/var/lwc_post.d when it makes, and this script executes all of those scripts. # use FIG_Config; use strict; use Errno qw(EEXIST EINVAL ESRCH EPERM); kick_services(); exit; sub kick_services { # # This is more grossness because we don't have a generalized mechanism # for registering services to be stopped and started. Must be coordinated # with the startup/shutdown code in FigKernelScripts/start_services.pl and # stop_services.pl. # # # Check to see if one of the services is running. If it is, invoke # stop_services and start_services. Otherwise, don't bother as we # don't want to start up services if they are currently stopped. # # We need to also check that the service is running as the same # user that we are running as. # my $pid_file = "$FIG_Config::fig_disk/config/seed_registration.pid"; if (not open(FH, "<$pid_file")) { # # Not there. just return. # return; } my $pid = <FH>; chop $pid; # # Try a kill with signal 0 to see if the process exists and if we might # be able to kill it. # if (kill(0, $pid) == 1) { # # We can do it. Do a stop/start services. # my $rc = system("$FIG_Config::bin/stop_services"); if ($rc != 0) { warn "lwc_postprocess: stop_services failed with rc=$rc\n"; } else { # # If we're running from a CGI, close STDIN and STDOUT to # keep things from hanging. # if (exists($ENV{SERVER_NAME})) { close(STDIN); close(STDOUT); } my $rc = system("$FIG_Config::bin/start_services"); if ($rc != 0) { warn "lwc_postprocess: start_services failed with rc=$rc\n"; } } } else { if ($! == ESRCH) { warn "lwc_postprocess: service process not found, not restarting services.\n"; } elsif ($! == EPERM) { warn "lwc_postprocess: services running as a different user, not restarting services.\n"; } else { warn "lwc_postprocess: Unknown error probing for existing service: $!\n"; } } }
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |