[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.2 - (download) (as text) (annotate)
Sun May 29 02:15:02 2005 UTC (15 years ago) by olson
Branch: MAIN
CVS Tags: merge-trunktag-bobdev_news-2, Root-bobdev_news, merge-bobdev_news-1, merge-trunktag-bobdev_news-1, merge-bodev_news-3, merge-bobdev_news-2, merge-trunktag-bodev_news-3
Branch point for: Branch-bobdev_news
Changes since 1.1: +65 -49 lines
Updates.

#
# 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;

use Getopt::Long;

my $sge_only = 0;

if (!GetOptions("sge-only" => \$sge_only))
{
    die "Usage: $0 [--sge-only]\n";
}

#
# Step 1.
#


if (not $sge_only)
{
    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.
#

if (not $sge_only)
{
    &FIG::run("$FIG_Config::ext_bin/mysqladmin -u root shutdown");
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3