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

Annotation of /FigCommon/lwc_postprocess.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3