[Bio] / FigKernelPackages / DBrtns.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/DBrtns.pm

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

revision 1.22, Tue Aug 16 19:41:12 2005 UTC revision 1.27, Thu Mar 2 22:19:45 2006 UTC
# Line 1  Line 1 
1    #
2    # Copyright (c) 2003-2006 University of Chicago and Fellowship
3    # for Interpretations of Genomes. All Rights Reserved.
4    #
5    # This file is part of the SEED Toolkit.
6    #
7    # The SEED Toolkit is free software. You can redistribute
8    # it and/or modify it under the terms of the SEED Toolkit
9    # Public License.
10    #
11    # You should have received a copy of the SEED Toolkit Public License
12    # along with this program; if not write to the University of Chicago
13    # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14    # Genomes at veronika@thefig.info or download a copy from
15    # http://www.theseed.org/LICENSE.TXT.
16    #
17    
18  package DBrtns;  package DBrtns;
19    
20      # Inherit the DBKernel methods. We must do this BEFORE the "use strict".      # Inherit the DBKernel methods. We must do this BEFORE the "use strict".
# Line 13  Line 30 
30  use Carp;  use Carp;
31    
32  sub new {  sub new {
33      my($class,$dbms,$dbname,$dbuser,$dbpass,$dbport, $dbhost) = @_;      my($class,$dbms,$dbname,$dbuser,$dbpass,$dbport, $dbhost, $dbsock) = @_;
34    
35      $dbms   = defined($dbms)   ? $dbms   : $FIG_Config::dbms;      $dbms   = defined($dbms)   ? $dbms   : $FIG_Config::dbms;
36      $dbname = defined($dbname) ? $dbname : $FIG_Config::db;      $dbname = defined($dbname) ? $dbname : $FIG_Config::db;
# Line 21  Line 38 
38      $dbpass = defined($dbpass) ? $dbpass : $FIG_Config::dbpass;      $dbpass = defined($dbpass) ? $dbpass : $FIG_Config::dbpass;
39      $dbport = defined($dbport) ? $dbport : $FIG_Config::dbport;      $dbport = defined($dbport) ? $dbport : $FIG_Config::dbport;
40      $dbhost = defined($dbhost) ? $dbhost : $FIG_Config::dbhost;      $dbhost = defined($dbhost) ? $dbhost : $FIG_Config::dbhost;
41        $dbsock = defined($dbsock) ? $dbsock : $FIG_Config::dbsock;
42    
43      return DBKernel::new($class, $dbms, $dbname, $dbuser, $dbpass, $dbport, $dbhost);      return DBKernel::new($class, $dbms, $dbname, $dbuser, $dbpass, $dbport, $dbhost, $dbsock);
44  }  }
45    
46  =head1 get_inserted_id  =head1 get_inserted_id
# Line 44  Line 62 
62          # print "mysql got $id\n";          # print "mysql got $id\n";
63          return $id;          return $id;
64      }      }
65        else
66        {
67            confess "Attempting get_inserted_id on unsupported database $self->{_dbms}\n";
68        }
69  }  }
70    
71  #  #
# Line 103  Line 125 
125          $exe = "mysql_install_db";          $exe = "mysql_install_db";
126      }      }
127    
128      my $rc = system($exe,  
129                      "--datadir=$db_dir",      my @opts;
130                      "--basedir=$FIG_Config::common_runtime",  
131                      "--user=$FIG_Config::dbuser");      push(@opts, "--datadir=$db_dir");
132        push(@opts, "--user=$FIG_Config::dbuser");
133    
134        if (not $FIG_Config::use_system_mysql)
135        {
136            push(@opts, "--basedir=$FIG_Config::common_runtime")
137        }
138    
139    
140        my $rc = system($exe, @opts);
141      if ($rc != 0)      if ($rc != 0)
142      {      {
143          my $err = $?;          my $err = $?;
# Line 161  Line 192 
192    
193      my(@opts);      my(@opts);
194    
195        my $cnf = "$FIG_Config::fig_disk/config/my.cnf";
196    
197        if ($FIG_Config::use_system_mysql)
198        {
199            #
200            # This has to be first in the argument list.
201            #
202            push(@opts, "--defaults-extra-file=$cnf");
203        }
204    
205        #
206        # Put this first, so  config can put --defaults-extra-file here
207        # and have it show up first.
208        #
209        if (@FIG_Config::db_server_startup_options)
210        {
211            push(@opts, @FIG_Config::db_server_startup_options)
212        }
213    
214      push(@opts, "--port=$FIG_Config::dbport");      push(@opts, "--port=$FIG_Config::dbport");
215      #      #
216      # Don't do this; dbuser isn't the unix uid that we are using.      # Don't do this; dbuser isn't the unix uid that we are using.
217      #      #
218      #push(@opts, "--user=$FIG_Config::dbuser");      #push(@opts, "--user=$FIG_Config::dbuser");
219      push(@opts, "--basedir=$FIG_Config::common_runtime");  
220      push(@opts, "--datadir=$FIG_Config::db_datadir");      push(@opts, "--datadir=$FIG_Config::db_datadir");
221    
222        if ($FIG_Config::use_system_mysql)
223        {
224            push(@opts, "--err-log=$FIG_Config::temp/mysql.log");
225            push(@opts, "--socket=$FIG_Config::dbsock");
226    
227            #
228            # Feh. You can't actually override the socket that /etc/my.cnf
229            # sets up, so we need to set up a config/my.cnf with the socket in it.
230            #
231    
232            if (! -f $cnf)
233            {
234                if (open(F, ">$cnf"))
235                {
236                    print F <<END;
237    [mysqld]
238    socket=$FIG_Config::dbsock
239    END
240                    close(F);
241                }
242            }
243        }
244        else
245        {
246            push(@opts, "--basedir=$FIG_Config::common_runtime");
247      push(@opts, "--ledir=$FIG_Config::common_runtime/libexec");      push(@opts, "--ledir=$FIG_Config::common_runtime/libexec");
248        }
249    
250        if (not $FIG_Config::mysql_v3)
251        {
252      push(@opts, "--old-password");      push(@opts, "--old-password");
253      push(@opts, "--max-allowed-packet=128M");      push(@opts, "--max-allowed-packet=128M");
254        }
255    
256      #      #
257      # Use InnoDB for large-table support and allegedly better performance.      # Use InnoDB for large-table support and allegedly better performance.
258      #      #
259    
260      push(@opts, "--default-table-type=innodb");      #push(@opts, "--default-table-type=innodb");
261    
262      #      #
263      # Oddly, this doesn't seem to work. need to set the environment variable.      # Oddly, this doesn't seem to work. need to set the environment variable.
264      #      #
265      #push(@opts, "--port=$FIG_Config::dbport");      #push(@opts, "--port=$FIG_Config::dbport");
266    
     if (@FIG_Config::db_server_startup_options)  
     {  
         push(@opts, @FIG_Config::db_server_startup_options)  
     }  
   
267      #      #
268      # We are going to assume that if mysql has shipped with this release, we'll use it. Otherwise      # We are going to assume that if mysql has shipped with this release, we'll use it. Otherwise
269      # try to use a system one.      # try to use a system one.
270      #      #
271    
272      my $exe = "$FIG_Config::ext_bin/mysqld_safe";      my $exe;
273        if ($FIG_Config::mysql_v3)
274      print "Start $exe @opts\n";      {
275      if (! -x $exe)          $exe = "safe_mysqld";
276        }
277        else
278      {      {
279          $exe = "mysqld_safe";          $exe = "mysqld_safe";
280      }      }
281    
282        if (-x "$FIG_Config::ext_bin/$exe")
283        {
284            $exe = "$FIG_Config::ext_bin/$exe";
285        }
286    
287        print "Start $exe @opts\n";
288    
289      if ($dont_fork)      if ($dont_fork)
290      {      {
291          $ENV{MYSQL_TCP_PORT} = $FIG_Config::dbport;          $ENV{MYSQL_TCP_PORT} = $FIG_Config::dbport;

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.27

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3