[Bio] / FigKernelScripts / boot_cluster_seed.pl Repository:
ViewVC logotype

View of /FigKernelScripts/boot_cluster_seed.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu May 12 15:27:50 2005 UTC (15 years, 2 months ago) by olson
Branch: MAIN
Bootup script for cluster node.

#
# Boot up a cluster-node SEED server. We assume we are using
# mysql with a snapshotted database directory.
#
# 1. See if $FIG_Config::db_datadir exists.  If it does,
#    go to step 3.
#
# 2. Extract $FIG_Config::db_snapshot_file into $FIG_Config::db_datadir.
#
# 3. Start the database server using start_dbserver.
#
# 4. Source the SEED environment setup file.
#
# 5. Start an SGE execution daemon.
#
# 6. Spin sleeping until the file FIGdisk/config/cluster_shutdown is created.
#
# 7. Shut down the SGE exec daemon.
#
# 8. Shut down the database server.
#
# 9. Exit.
#

use strict;

use FIG;
use FIG_Config;

use File::Basename;

use LWP::UserAgent;

#
# Step 1.
#

if (-d $FIG_Config::db_datadir)
{
    #
    # See if the size is right
    #
    my $szout = `du -ks $FIG_Config::db_datadir`;
    my($sz) = $szout =~ /(\d+)/;
    print "Computed size as $sz want $FIG_Config::db_datadir_size\n";

    if ($sz != $FIG_Config::db_datadir_size)
    {
	print "Removing invalid datadir \n";
	system("rm -rf $FIG_Config::db_datadir");
    }
}

if (! -d $FIG_Config::db_datadir)
{
    #
    # Step 2.
    #

    my $dir = dirname($FIG_Config::db_datadir);
    &FIG::verify_dir($dir);

    print "Extract db snapshot from $FIG_Config::db_snapshot_file to $dir\n";
    &FIG::run("cd $dir; tar xzfp $FIG_Config::db_snapshot_file");
}

if (! -d $FIG_Config::db_datadir)
{
    die "After extract, data directory $FIG_Config::db_datadir does not exist\n";
}

#
# Step 3.
#

&FIG::run("$FIG_Config::bin/start_dbserver");

#
# Wait a bit for the db to come up.
#

sleep 5;

my $fig;
eval {
    $fig = new FIG;
};

if ($@)
{
    die "Could not connect to database: $@\n";
}

#
# Step 4/5.
#

my $celldir = "$FIG_Config::fig_disk/gendb/SGE/default";
&FIG::run("source $FIG_Config::fig_disk/config/fig-user-env.sh; $celldir/common/sgeexecd start");

#
# Step 6.
#
# Due to GPFS weirdness, we can't actually do this. Substitute a URL get.
#

if(0)
{
    while (! -f "$FIG_Config::fig_disk/config/cluster_shutdown")
    {
	sleep(1);
    }
}

my $ua = new LWP::UserAgent;
my $url = "http://tp-login1.uchicago.edu/~olson/cluster_shutdown";

while (1)
{
    my $resp = $ua->get($url);
    if ($resp->is_success())
    {
	last;
    }
    sleep 10;
}

print "Shutting down cluster node\n";

#
# Step 7.
#

&FIG::run("source $FIG_Config::fig_disk/config/fig-user-env.sh; $celldir/common/sgeexecd stop");

#
# Step 8.
#

&FIG::run("$FIG_Config::ext_bin/mysqladmin -u root shutdown");


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3