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

Diff of /FigKernelScripts/boot_cluster_seed.pl

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

revision 1.2, Sun May 29 02:15:02 2005 UTC revision 1.3, Wed Jul 27 22:13:15 2005 UTC
# Line 35  Line 35 
35    
36  my $sge_only = 0;  my $sge_only = 0;
37    
38    $SIG{TERM} = \&shutdown_sig;
39    $SIG{INT} = \&shutdown_sig;
40    $SIG{HUP} = \&shutdown_sig;
41    
42    our $sge_running = 0;
43    our $db_running = 0;
44    
45  if (!GetOptions("sge-only" => \$sge_only))  if (!GetOptions("sge-only" => \$sge_only))
46  {  {
47      die "Usage: $0 [--sge-only]\n";      die "Usage: $0 [--sge-only]\n";
48  }  }
49    
50    my $celldir = $FIG_Config::sge_cell_dir;
51    if (!defined($celldir))
52    {
53        die "SGE cell directory not specified in FIG_Config::sge_cell_dir\n";
54    }
55    elsif (! -d $celldir)
56    {
57        die "SGE cell directory $celldir not found\n";
58    }
59    
60  #  #
61  # Step 1.  # Step 1.
62  #  #
# Line 52  Line 69 
69          #          #
70          # See if the size is right          # See if the size is right
71          #          #
         my $szout = `du -ks $FIG_Config::db_datadir`;  
         my($sz) = $szout =~ /(\d+)/;  
         print "Computed size as $sz want $FIG_Config::db_datadir_size\n";  
72    
73          if ($sz != $FIG_Config::db_datadir_size)          my $sum = `cd $FIG_Config::db_datadir; ls -lR  | grep -v err | awk '{print \$5, \$8}'|md5sum | awk '{print \$1}'`;
74            chomp($sum);
75    
76            print "Computed size as '$sum' want $FIG_Config::db_datadir_size\n";
77    
78            if ($sum != $FIG_Config::db_datadir_size)
79          {          {
80              print "Removing invalid datadir \n";              print "Removing invalid datadir \n";
81              system("rm -rf $FIG_Config::db_datadir");              system("rm -rf $FIG_Config::db_datadir");
# Line 87  Line 106 
106    
107      &FIG::run("$FIG_Config::bin/start_dbserver");      &FIG::run("$FIG_Config::bin/start_dbserver");
108    
109        $db_running = 1;
110    
111      #      #
112      # Wait a bit for the db to come up.      # Wait a bit for the db to come up.
113      #      #
114    
115        my $give_up = time + 10 * 60;
116        my $ok;
117        while (time < $give_up)
118        {
119      sleep 5;      sleep 5;
120    
121      my $fig;      my $fig;
# Line 100  Line 125 
125    
126      if ($@)      if ($@)
127      {      {
128          die "Could not connect to database: $@\n";              warn "Could not connect to database: $@\n";
129            }
130            else
131            {
132                $ok = 1;
133                last;
134            }
135        }
136    
137        if (not $ok)
138        {
139            warn "Could not connect to database for ten minutes, giving up\n";
140            shutdown_seed();
141      }      }
142  }  }
143    
# Line 108  Line 145 
145  # Step 4/5.  # Step 4/5.
146  #  #
147    
148  my $celldir = "$FIG_Config::fig_disk/gendb/SGE/default";  my $sge_cmd = "source $FIG_Config::fig_disk/config/fig-user-env.sh; $celldir/common/sgeexecd start";
149  &FIG::run("source $FIG_Config::fig_disk/config/fig-user-env.sh; $celldir/common/sgeexecd start");  warn "Starting sge: $sge_cmd\n";
150    my $rc = system($sge_cmd);
151    if ($rc != 0)
152    {
153        warn "Return code $rc from attempt to start sge daemon\n";
154        my $out = `ps auxw|grep sge_execd|grep -v grep`;
155        if ($out !~ /sge_execd/)
156        {
157            warn "sge_execd process not found, quitting\n";
158            shutdown_seed();
159        }
160    }
161    $sge_running = 1;
162    
163  #  #
164  # Step 6.  # Step 6.
# Line 140  Line 189 
189    
190  print "Shutting down cluster node\n";  print "Shutting down cluster node\n";
191    
192    shutdown_seed();
193    exit(0);
194    
195    sub shutdown_sig
196    {
197        my($sig) = @_;
198        print "Shutting down due to signal $sig\n";
199        shutdown_seed();
200    }
201    
202    sub shutdown_seed
203    {
204        my($sig) = @_;
205  #  #
206  # Step 7.  # Step 7.
207  #  #
208    
209  &FIG::run("source $FIG_Config::fig_disk/config/fig-user-env.sh; $celldir/common/sgeexecd stop");      if ($sge_running)
210        {
211            system("source $FIG_Config::fig_disk/config/fig-user-env.sh; $celldir/common/sgeexecd stop");
212        }
213    
214  #  #
215  # Step 8.  # Step 8.
216  #  #
217    
218  if (not $sge_only)      if ($db_running)
219  {  {
220      &FIG::run("$FIG_Config::ext_bin/mysqladmin -u root shutdown");          system("$FIG_Config::ext_bin/mysqladmin -u root shutdown");
221        }
222    
223        exit(0);
224  }  }
225    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3