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

Annotation of /FigCommon/lwc_postprocess.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (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 :     my $rc = system("$FIG_Config::bin/start_services");
69 :     if ($rc != 0)
70 :     {
71 :     warn "lwc_postprocess: start_services failed with rc=$rc\n";
72 :     }
73 :     }
74 :     }
75 :     else
76 :     {
77 :     if ($! == ESRCH)
78 :     {
79 :     warn "lwc_postprocess: service process not found, not restarting services.\n";
80 :     }
81 :     elsif ($! == EPERM)
82 :     {
83 :     warn "lwc_postprocess: services running as a different user, not restarting services.\n";
84 :     }
85 :     else
86 :     {
87 :     warn "lwc_postprocess: Unknown error probing for existing service: $!\n";
88 :     }
89 :     }
90 :    
91 :     }
92 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3