[Bio] / Sprout / ERDBLoadKill.pl Repository:
ViewVC logotype

Annotation of /Sprout/ERDBLoadKill.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     #
4 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
5 :     # for Interpretations of Genomes. All Rights Reserved.
6 :     #
7 :     # This file is part of the SEED Toolkit.
8 :     #
9 :     # The SEED Toolkit is free software. You can redistribute
10 :     # it and/or modify it under the terms of the SEED Toolkit
11 :     # Public License.
12 :     #
13 :     # You should have received a copy of the SEED Toolkit Public License
14 :     # along with this program; if not write to the University of Chicago
15 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
16 :     # Genomes at veronika@thefig.info or download a copy from
17 :     # http://www.theseed.org/LICENSE.TXT.
18 :     #
19 :    
20 :     use strict;
21 :     use Tracer;
22 :     use ERDB;
23 :     use ERDBLoadGroup;
24 :    
25 :     =head1 ERDBLoadKill Script
26 :    
27 :     ERDBLoadKill [options]
28 :    
29 :     ERDB Load Killer
30 :    
31 :     =head2 Introduction
32 :    
33 :     Tell any active load processes to terminate at the end of the current operation.
34 :     This script creates a special marker file in the load directory. When
35 :     load-related programs see the file, they stop.
36 :    
37 :     =head2 Command-Line Options
38 :    
39 :     =over 4
40 :    
41 :     =item trace
42 :    
43 :     Specifies the tracing level. The higher the tracing level, the more messages
44 :     will appear in the trace log. Use E to specify emergency tracing.
45 :    
46 :     =item user
47 :    
48 :     Name suffix to be used for log files. If omitted, the PID is used.
49 :    
50 :     =item sql
51 :    
52 :     If specified, turns on tracing of SQL activity.
53 :    
54 :     =item background
55 :    
56 :     Save the standard and error output to files. The files will be created
57 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
58 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
59 :     B<user> option above.
60 :    
61 :     =item help
62 :    
63 :     Display this command's parameters and options.
64 :    
65 :     =item warn
66 :    
67 :     Create an event in the RSS feed when an error occurs.
68 :    
69 :     =item phone
70 :    
71 :     Phone number to message when the script is complete.
72 :    
73 :     =back
74 :    
75 :     =cut
76 :    
77 :     # Get the command-line options and parameters.
78 :     my ($options, @parameters) = StandardSetup([qw(ERDBLoadGroup ERDB ERDBGenerator) ],
79 :     {
80 :     trace => ["2", "tracing level"],
81 :     forked => [1, "do not erase the trace file"],
82 :     phone => ["", "phone number (international format) to call when load finishes"]
83 :     },
84 :     "",
85 :     @ARGV);
86 :     # Set a variable to contain return type information.
87 :     my $rtype;
88 :     # Insure we catch errors.
89 :     eval {
90 :     # Get the database name.
91 :     my $dbName = $parameters[0];
92 :     # Complain if we don't have one.
93 :     Confess("No database name specified.") if ! defined $dbName;
94 :     # Get the database object.
95 :     my $erdb = ERDB::GetDatabase($dbName);
96 :     # Get the name of the load directory for this database.
97 :     my $directory = $erdb->LoadDirectory();
98 :     # Compute the kill file name.
99 :     my $fileName = ERDBLoadGroup::KillFileName($erdb, $directory);
100 :     # Create the kill file.
101 :     my $oh = Open(undef, ">$fileName");
102 :     print $oh "Kill request made by process $$ and user $<.\n";
103 :     close $oh;
104 :     Trace("Kill file $fileName created.") if T(2);
105 :     };
106 :     if ($@) {
107 :     Trace("Script failed with error: $@") if T(0);
108 :     $rtype = "error";
109 :     } else {
110 :     Trace("Script complete.") if T(2);
111 :     $rtype = "no error";
112 :     }
113 :     if ($options->{phone}) {
114 :     my $msgID = Tracer::SendSMS($options->{phone}, "ERDBLoadKill terminated with $rtype.");
115 :     if ($msgID) {
116 :     Trace("Phone message sent with ID $msgID.") if T(2);
117 :     } else {
118 :     Trace("Phone message not sent.") if T(2);
119 :     }
120 :     }
121 :    
122 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3