File Coverage

blib/lib/Bio/GMOD/Admin/Monitor/acedb.pm
Criterion Covered Total %
statement 12 35 34.2
branch 0 10 0.0
condition 0 6 0.0
subroutine 4 6 66.6
pod 2 2 100.0
total 18 59 30.5


line stmt bran cond sub pod time code
1             package Bio::GMOD::Admin::Monitor::acedb;
2              
3             # Monitor and restart acedb as needed
4              
5 1     1   29433 use strict;
  1         3  
  1         40  
6 1     1   5 use vars qw/@ISA/;
  1         2  
  1         55  
7 1     1   634 use Bio::GMOD::Admin::Monitor;
  1         3  
  1         36  
8 1     1   7 use Bio::GMOD::Util::Rearrange;
  1         2  
  1         432  
9              
10             @ISA = qw/Bio::GMOD::Admin::Monitor/;
11              
12             # Check that sgifaceserver is running on the provided port
13             sub check_status {
14 0     0 1   my ($self,@p) = @_;
15              
16 0           my @ps = `ps -aux | grep sgifaceserver`;
17 0           my $is_up;
18 0           foreach (@ps) {
19 0 0         $is_up++ if (/sgifaceserver\s\//);
20             }
21            
22 0           $self->{testing} = 'acedb';
23 0           $self->{tested_at} = $self->fetch_date;
24 0 0         my ($string,$status) = $self->set_status(-timing => 'initial',
25             -msg => "Testing acedb/sgifaceserver",
26             -status => ($is_up) ? 'up' : 'down');
27 0           return ($string,$status);
28             }
29              
30             sub restart {
31 0     0 1   my ($self,@p) = @_;
32 0           my ($xinetd,$user,$pass) = rearrange([qw/XINETD USER PASS/],@p);
33 0   0       $xinetd ||= '/etc/rc.d/init.d/xinetd';
34 0   0       $user ||= 'admin';
35 0   0       $pass ||= 'ace123';
36            
37             # Try restarting sgiface from least to most aggressive
38 0           my $result = (system "/usr/local/acedb/bin/ace.pl -port 2005 -user $user -pass $pass -e 'shutdown now'");
39            
40             # Try restarting xinetd
41 0           $result = system($xinetd,'reload');
42            
43             # Directly restart xinetd on some systems
44 0 0         $result = system('killall -HUP xinetd') unless ($result == 0);
45            
46             # Try restarting via inetd
47 0 0         $result = system('killall -HUP inetd') unless ($result == 0);
48            
49 0           my ($string,$status);
50 0 0         if ($result != 0) {
51 0           ($string,$status) = $self->set_status(-timing => 'final',
52             -msg => "Restarting acedb/sgifaceserver/xinetd",
53             -status => 'failed');
54             } else {
55 0           ($string,$status) = $self->set_status(-timing => 'final',
56             -msg => "Restarting acedb/sgifaceserver/xinetd",
57             -status => 'succeeded');
58             }
59 0           return ($string,$status);
60             }
61              
62              
63             1;
64              
65              
66             =pod
67              
68             =head1 NAME
69              
70             Bio::GMOD::Admin::Monitor::acedb - Monitor acedb/sgifaceserver
71              
72             =head1 SYNOPSIS
73              
74             Check that sgifaceserver is running
75              
76             use Bio::GMOD::Admin::Monitor::acedb;
77             my $gmod = Bio::GMOD::Admin::Monitor::acedb->new();
78             $gmod->check_status();
79             print "Testing acedb status at " . $gmod->tested_at . ": $status";
80              
81             =head1 DESCRIPTION
82              
83             Bio::GMOD::Admin::Monitor::acedb provides methods for monitoring and
84             restarting acedb/sgifaceserver as necessary.
85              
86             =head1 PUBLIC METHODS
87              
88             =over 4
89              
90             =item $gmod->check_status()
91              
92             Check the status of acedb on the localhost. Note that because in most
93             installations, sgifaceserver is configured to run under xinetd/inetd.
94             If there has been a long period with no requests, sgifaceserver may
95             have timed out.
96              
97             This method returns a two element list comprised of ($string,$status).
98             $string will contain a formatted string indicating the test, time, and
99             result; $status will be boolean true or false indicating the success
100             or failure of the test.
101              
102             This method also populates the object with a variety of status
103             strings. See the "ACCESSOR METHODS" section of Bio::GMOD::Admin::Monitor for
104             additional details.
105              
106             =item $monitor->restart(@options);
107              
108             Restart sgifaceserver using a variety of methods, starting from least
109             to most aggressive.
110              
111             Options:
112             -user These two options will be used to try and restart sgifaceserver
113             -pass using the ace.pl script (if installed on your system) (admin/ace123)
114              
115             -xinetd full path to xinetd undet control of init.d
116             (defaults to /etc/rc.d/init.d/xinetd if not provided)
117              
118             The following attempts will be made to try and restart sgifaceserver:
119              
120             1. via ace.pl
121             2. By reloading xinetd through inetd
122             3. By sending xinetd a HUP
123             4. By sending inetd a HUP
124              
125             Note that restarting sgifaceserver can take some time depending on
126             your system! Be patient!
127              
128             This method returns a two element list comprised of ($string,$status).
129             $string will contain a formatted string indicating the test, time, and
130             result; $status will be boolean true or false indicating the success
131             or failure of the test.
132              
133             Like check_status(), this method populates a number of status
134             fields in the object. See the "ACCESSOR METHODS" section of
135             Bio::GMOD::Admin::Monitor for additional details.
136              
137             =back
138              
139             =head1 BUGS
140              
141             None reported.
142              
143             =head1 SEE ALSO
144              
145             L, L
146              
147             =head1 AUTHOR
148              
149             Todd W. Harris Eharris@cshl.orgE.
150              
151             Copyright (c) 2003-2005 Cold Spring Harbor Laboratory.
152              
153             This library is free software; you can redistribute it and/or modify
154             it under the same terms as Perl itself.
155              
156             =cut