[Bio] / FigWebServices / seed_ctl.cgi Repository:
ViewVC logotype

Diff of /FigWebServices/seed_ctl.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Mon Jun 14 22:05:38 2004 UTC revision 1.3, Wed Jun 16 14:06:48 2004 UTC
# Line 14  Line 14 
14    
15  use strict;  use strict;
16    
17    use Text::Wrap;
18  use POSIX;  use POSIX;
19    
20  use CGI;  use CGI;
# Line 60  Line 61 
61      # Fork a process to run the rebuild scripts.      # Fork a process to run the rebuild scripts.
62      #      #
63    
     my $child = fork;  
   
     if (!$child)  
     {  
         #  
         # In the child  
         #  
   
         POSIX::setsid();  
   
64          my $add = "$FIG_Config::bin/add_assertions_of_function";          my $add = "$FIG_Config::bin/add_assertions_of_function";
65          my $mkindex = "$FIG_Config::bin/make_indexes";          my $mkindex = "$FIG_Config::bin/make_indexes";
66    
67          my $job_file = "$job_dir/$$";      $fig->run_in_background(sub {
68    
69            print "Running $add\n";
         open(my $fh, ">$job_file");  
         print $fh "Running $add\n";  
         close($fh);  
70    
71          open(my $fh, ">$down_file");          open(my $fh, ">$down_file");
72          print $fh "SEED server is rebuilding indexes.\n";          print $fh "SEED server is rebuilding indexes.\n";
# Line 87  Line 75 
75    
76          system($add);          system($add);
77    
78          open my $fh, ">>$job_file";          print "Running $mkindex\n";
         print $fh "Running $mkindex\n";  
         close($fh);  
79    
80          open my $fh, ">>$down_file";          open my $fh, ">>$down_file";
81          print $fh "Running $mkindex\n";          print $fh "Running $mkindex\n";
# Line 97  Line 83 
83    
84          system($mkindex);          system($mkindex);
85    
86          unlink($job_file);          print "Complete\n";
87    
88          unlink($down_file);          unlink($down_file);
89      }      });
90  }  }
91    
92  #  #
# Line 154  Line 141 
141    
142  push(@html, $cgi->h2("SEED status"));  push(@html, $cgi->h2("SEED status"));
143    
144    my $uptime = `uptime`;
145    if ($uptime =~ /load average(s?):\s+(.*)/)
146    {
147        push(@html, "Server load averages: $2<p>\n");
148    }
149    
150  if (-f $down_file)  if (-f $down_file)
151  {  {
# Line 185  Line 177 
177  push(@html, $cgi->h2("Background jobs"));  push(@html, $cgi->h2("Background jobs"));
178  push(@html, "\n");  push(@html, "\n");
179    
180    if ($cgi->param("show_output"))
181    {
182        my $job = $cgi->param("show_output");
183    
184        push(@html, $cgi->hr);
185    
186        push(@html, $cgi->h2("Job $job output"));
187        open(my $fh, "<$job_dir/$job/OUTPUT");
188        push(@html, "<pre>");
189    
190        while (<$fh>)
191        {
192            push(@html, $_);
193        }
194        close($fh);
195    
196        push(@html, "</pre>");
197        push(@html, $cgi->hr);
198    }
199  opendir(D, $job_dir);  opendir(D, $job_dir);
200  my @jobs = grep { $_ =~ /^\d+$/ } readdir(D);  my @jobs = grep { $_ =~ /^\d+$/ } readdir(D);
201    
# Line 197  Line 208 
208    
209      for my $job (@jobs)      for my $job (@jobs)
210      {      {
211          my($running, $status, $but, $output, $info);          my($running, $status, $but, @output, $info, $output);
212    
213          if (kill(0, $job) > 0)          if (kill(0, $job) > 0)
214          {          {
# Line 212  Line 223 
223    
224          $status = &FIG::file_read("$job_dir/$job/STATUS");          $status = &FIG::file_read("$job_dir/$job/STATUS");
225          $info = &FIG::file_read("$job_dir/$job/INFO");          $info = &FIG::file_read("$job_dir/$job/INFO");
226          $output = &FIG::file_read("$job_dir/$job/OUTPUT");          @output = &FIG::file_read("$job_dir/$job/OUTPUT");
227            my $outlink;
228    
229            if (@output > 10)
230            {
231                splice(@output, 0, @output - 10);
232                my $link = "seed_ctl.cgi?show_output=$job";
233                $outlink = "<a href=\"$link\">Show full output</a>\n";
234            }
235    
236          push(@$tbl, [$job, $running, $status, $info, "<pre>$output</pre>", $but]);          $Text::Wrap::columns = 60;
237            $output = wrap('', '', @output);
238            $output = "<pre>$output\n</pre><br>$outlink\n";
239            push(@$tbl, [$job, $running, $status, $info, $output, $but]);
240      }      }
241      push(@html, &HTML::make_table(\@hdrs, $tbl));      push(@html, &HTML::make_table(\@hdrs, $tbl));
242  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3