[Bio] / SubsystemExtension / check_subsystem_extension.pl Repository:
ViewVC logotype

View of /SubsystemExtension/check_subsystem_extension.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (as text) (annotate)
Thu May 4 04:12:24 2006 UTC (12 years, 11 months ago) by overbeek
Branch: MAIN
RAE: Adding automatic subsystems extension and queue to Heikos tool

use strict;
use warnings;

use FIG;
my $fig = new FIG;
use FileLocking;
use SubsystemExtension::ExtensionConfig qw (TEMPDIR);


=head1 check_subsystem_extension.pl

This script should be run as a cron job. It will check for presence of the file enqueued_extensions
in the SubsystemExtension::ExtensionConfig TEMPDIR directory which is usu. FIG/Tmp/aeos/

If that file is present it will copy that to currently_extending which then also acts as a flag to tell us
that another job is running, in which case we won't continue.

Then all we do is just run the multiple_subsystem_extension command to actually take care of the update.


Things that need changing:
    1. The locations of the files 
        my $file=TEMPDIR."enqueued_extensions";
        my $extending_file=TEMPDIR."currently_extending";

        These should be updated to grab the updates from other machines (or, alternatively, the enqueue_extension
        method in SubsystemExtension/ExtensionInterface/SEED.pm should be modded to write to rickettsia)

    2. The location of the output
            my $output=TEMPDIR;
            this should be changed to be the TEMPDIR location on Yersinia

    3. The run_in_background command should really be changed to submitting through the SGE queue


# this script will check for the file enqueued_extensions and if it is there it will enqueue those for updating
my $file=TEMPDIR."enqueued_extensions"; # this is the file that contains the list of ss to be updated
exit(0) unless (-e $file); # don't carry on if there is nothing to do

# now check that we are not still extending other subsystems
my $extending_file=TEMPDIR."currently_extending";
exit(0) if (-e $extending_file); # we are still extending other subsystems

# lock the file that has the list of ss to update, read that file and write out a flattened list
# to the extending_file

    my %to_update; # a hash of the one's that we'll update
    my $lockobj = FileLocking->lock_file($file);
    open(IN, $file) || die "Can't open $file";
    while (<IN>) {$to_update{$_}=1} # this will avoid extending subsystems more than once when someone presses the button lots of times :)
    close IN;
    open(OUT, ">$extending_file") || die "Can't write to $extending_file";
    print OUT keys %to_update;
    close OUT;
    unlink($file); # not sure that I can do this while it is locked?

# now all we have to do is run the update on $extending_file and finally delete that file

# output is where we want the output. change this to be TEMPDIR on yersinia
my $output=TEMPDIR;
my $command = $FIG_Config::bin."/multiple_subsystem_extension -d $output -f $extending_file -a";

#print STDERR "Running \n$command\n";

# run in background. This should really be submit to the SGE queue
my $bkj=$fig->run_in_background(sub 
            my $time=time;
            print "Automatically extending the subsystems started at: ", scalar(localtime($time)), "\n";
            print "Complete at ", scalar(localtime(time)), ". Running took ", (time-$time)/60, " minutes\n";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3