[Bio] / FigCommon / lwc_postprocess.pl Repository:
ViewVC logotype

Annotation of /FigCommon/lwc_postprocess.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download) (as text)

1 : olson 1.1 #
2 :     # This script is invoked after a lightweight code update has completed.
3 :     #
4 :     # It is used to kick the services scripts if they are running so that
5 :     # they pick up any new code.
6 :     #
7 :     # In addition, I anticipate this being the place to hook any per-module functionality
8 :     # that might need a post-lwc step. The scheme would probably be a module writes
9 :     # a file into FIG/var/lwc_post.d when it makes, and this script executes all of those scripts.
10 :     #
11 :    
12 :     use FIG_Config;
13 :     use strict;
14 :     use Errno qw(EEXIST EINVAL ESRCH EPERM);
15 :    
16 :     kick_services();
17 :    
18 :     exit;
19 :    
20 :     sub kick_services
21 :     {
22 :     #
23 :     # This is more grossness because we don't have a generalized mechanism
24 :     # for registering services to be stopped and started. Must be coordinated
25 :     # with the startup/shutdown code in FigKernelScripts/start_services.pl and
26 :     # stop_services.pl.
27 :     #
28 :    
29 :     #
30 :     # Check to see if one of the services is running. If it is, invoke
31 :     # stop_services and start_services. Otherwise, don't bother as we
32 :     # don't want to start up services if they are currently stopped.
33 :     #
34 :     # We need to also check that the service is running as the same
35 :     # user that we are running as.
36 :     #
37 :    
38 :     my $pid_file = "$FIG_Config::fig_disk/config/seed_registration.pid";
39 :     if (not open(FH, "<$pid_file"))
40 :     {
41 :     #
42 :     # Not there. just return.
43 :     #
44 :    
45 :     return;
46 :     }
47 :    
48 :     my $pid = <FH>;
49 :     chop $pid;
50 :    
51 :     #
52 :     # Try a kill with signal 0 to see if the process exists and if we might
53 :     # be able to kill it.
54 :     #
55 :    
56 :     if (kill(0, $pid) == 1)
57 :     {
58 :     #
59 :     # We can do it. Do a stop/start services.
60 :     #
61 :     my $rc = system("$FIG_Config::bin/stop_services");
62 :     if ($rc != 0)
63 :     {
64 :     warn "lwc_postprocess: stop_services failed with rc=$rc\n";
65 :     }
66 :     else
67 :     {
68 : olson 1.2 #
69 :     # If we're running from a CGI, close STDIN and STDOUT to
70 :     # keep things from hanging.
71 :     #
72 :    
73 : olson 1.3 #if (exists($ENV{SERVER_NAME}))
74 : olson 1.2 {
75 :     close(STDIN);
76 :     close(STDOUT);
77 : olson 1.3 close(STDERR);
78 : olson 1.2 }
79 :    
80 : olson 1.1 my $rc = system("$FIG_Config::bin/start_services");
81 :     if ($rc != 0)
82 :     {
83 :     warn "lwc_postprocess: start_services failed with rc=$rc\n";
84 :     }
85 :     }
86 :     }
87 :     else
88 :     {
89 :     if ($! == ESRCH)
90 :     {
91 :     warn "lwc_postprocess: service process not found, not restarting services.\n";
92 :     }
93 :     elsif ($! == EPERM)
94 :     {
95 :     warn "lwc_postprocess: services running as a different user, not restarting services.\n";
96 :     }
97 :     else
98 :     {
99 :     warn "lwc_postprocess: Unknown error probing for existing service: $!\n";
100 :     }
101 :     }
102 :    
103 :     }
104 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3