|
From: Chris W. <la...@us...> - 2001-11-06 14:41:17
|
Update of /cvsroot/openinteract/OpenInteract/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv8741
Modified Files:
ApacheStartup.pm
Log Message:
NOTE: THIS RELIES ON CHANGES TO THE APACHE CONFIG; created a more
self-contained childinit handler so that we don't generate SPOPS
classes until the child init rather than at server startup
Index: ApacheStartup.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/OpenInteract/ApacheStartup.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** ApacheStartup.pm 2001/10/08 21:34:41 1.16
--- ApacheStartup.pm 2001/11/06 14:34:15 1.17
***************
*** 4,7 ****
--- 4,8 ----
use strict;
+ use Apache::DBI;
use OpenInteract::DBI;
use OpenInteract::Startup;
***************
*** 36,40 ****
my $BASE_CONFIG = OpenInteract::Startup->read_base_config({ filename => $bc_file });
unless ( $BASE_CONFIG ) { die "Cannot create base configuration from ($bc_file)!"; }
! DEBUG && _w( 1, " --base configuration read in ok." );
# Read in all the Apache classes -- do this separately since we need
--- 37,41 ----
my $BASE_CONFIG = OpenInteract::Startup->read_base_config({ filename => $bc_file });
unless ( $BASE_CONFIG ) { die "Cannot create base configuration from ($bc_file)!"; }
! DEBUG && _w( 1, "SERVER INIT: base configuration read in ok." );
# Read in all the Apache classes -- do this separately since we need
***************
*** 51,74 ****
$BASE_CONFIG->{config_dir} );
OpenInteract::Startup->require_module({ filename => "$config_dir/apache.dat" });
! DEBUG && _w( 1, " --apache modules read in ok." );
!
! # The big enchilada -- do just about everything here and get back the
! # list of classes that need to be initialized along with the config object.
! # Note that we do not pass the necessary parameters to initialize aliases
! # and to create/initialize the SPOPS classes -- we do that in the child
! # init handler below
!
! my ( $init_class, $C ) = OpenInteract::Startup->main_initialize({
! base_config => $BASE_CONFIG });
! unless ( $C ) { die "No configuration object returned from initialization!\n"; }
! DEBUG && _w( 1, " --main initialization completed ok." );
!
! OpenInteract::Startup->require_module({ class => $C->{session_info}{class} });
! DEBUG && _w( 1, " -- require the session class ok" );
!
! # Figure out how to do this more cleanly in the near future -- maybe
! # just do it by hand for this special class?
! push @{ $init_class }, 'OpenInteract::PackageRepository';
# Initialize the DBI drivers. Stas Beckman (st...@st...) wrote
--- 52,58 ----
$BASE_CONFIG->{config_dir} );
OpenInteract::Startup->require_module({ filename => "$config_dir/apache.dat" });
! DEBUG && _w( 1, "SERVER INIT: apache modules read in ok." );
! my $C = OpenInteract::Startup->create_config({ base_config => $BASE_CONFIG });
# Initialize the DBI drivers. Stas Beckman (st...@st...) wrote
***************
*** 82,86 ****
next if ( $dbd_installed{ $db_info->{ $db_key }{driver_name} } );
DBI->install_driver( $db_info->{ $db_key }{driver_name} );
! DEBUG && _w( 1, " --installed DBD driver ($db_info->{ $db_key }{driver_name}) ok." );
}
--- 66,70 ----
next if ( $dbd_installed{ $db_info->{ $db_key }{driver_name} } );
DBI->install_driver( $db_info->{ $db_key }{driver_name} );
! DEBUG && _w( 1, "SERVER INIT: installed DBD driver ($db_info->{ $db_key }{driver_name}) ok." );
}
***************
*** 92,104 ****
eval $PROXY_SUB;
die "Cannot create proxy subroutine! $@" if ( $@ );
! DEBUG && _w( 1, " --installed proxy subroutine ok." );
}
- # Setup caching info for use in the child init handler below
-
- my $cache_info = $C->{cache_info}{data};
- my $cache_class = $cache_info->{class};
- my $ipc_cache_class = $C->{cache}{ipc}{class};
-
# If we're told, cleanup the Template Toolkit compile directory
--- 76,82 ----
eval $PROXY_SUB;
die "Cannot create proxy subroutine! $@" if ( $@ );
! DEBUG && _w( 1, "SERVER INIT: installed proxy subroutine ok." );
}
# If we're told, cleanup the Template Toolkit compile directory
***************
*** 107,189 ****
}
! # Do these initializations every time, unless we're on Win32 (they
! # have just call the routine to call something else...)
! my ( $init_sub, $OS );
! unless ($OS = $^O) {
! require Config;
! $OS = $Config::Config{'osname'};
! }
- # See the second sub for comments...
! if ( $OS=~/Win/i ) {
! DEBUG && _w( 1, "Running initialization for Windows." );
! srand;
! $cache_class->class_initialize({ config => $C }) if ( $cache_info->{use} );
! $ipc_cache_class->class_initialize({ config => $C }) if ( $cache_info->{use_ipc} );
! my $REQUEST_CLASS = $BASE_CONFIG->{request_class};
! $REQUEST_CLASS->setup_aliases;
! OpenInteract::Startup->initialize_spops({ config => $C, class => $init_class });
! eval { OpenInteract::Error::Main->initialize({ config => $C }) };
! my $err_status = ( $@ ) ? $@ : 'ok';
! DEBUG && _w( 1, sprintf( "%-40s: %-30s","init: Error Dispatcher", $err_status ) );
! }
! else {
! DEBUG && _w( 1, "Seeding childinit handler (non-Windows)" );
! my $init_sub = sub {
! DEBUG && _w( 1, "PerlChildInitHandler being executed for Child ($$)" );
! # seed the random number generator per child -- note that we can
! # probably take this out as of mod_perl >= 1.25
! srand;
! # Connect to the db but throw away the handle that is returned
! # -- this just 'primes the pump' and makes the DB connection
! # when the child is started versus when the first request is
! # received (probably not necessary using mysql, but for heavier
! # databases it can be a Good Thing)
! # TODO: See if this is the reason why we get the 'not
! # creating $R' problems discussed briefly at the bottom of
! # OpenInteract.pm
! foreach my $db_key ( keys %{ $db_info } ) {
! eval { OpenInteract::DBI->connect( $db_info->{ $db_key } ) };
! if ( $@ ) {
! warn "Error trying to run first connect for database ",
! "connection key ($db_key): $@\n";
! }
! }
! $cache_class->class_initialize({ config => $C }) if ( $cache_info->{use} );
! $ipc_cache_class->class_initialize({ config => $C }) if ( $cache_info->{use_ipc} );
! # Tell OpenInteract::Request to setup aliases if it hasn't already
! my $REQUEST_CLASS = $BASE_CONFIG->{request_class};
! $REQUEST_CLASS->setup_aliases;
! # Initialize all the SPOPS object classes
! OpenInteract::Startup->initialize_spops({ config => $C,
! class => $init_class });
! # Create a list of error handlers for our website
! eval { OpenInteract::Error::Main->initialize({ config => $C }) };
! my $err_status = ( $@ ) ? $@ : 'ok';
! DEBUG && _w( 0, sprintf( "%-40s: %-30s","init: Error Dispatcher", $err_status ) );
! };
! Apache->push_handlers( PerlChildInitHandler => $init_sub );
! }
}
--- 85,158 ----
}
! # This should now work on both Win32 and Unix, without separate
! # handlers for both
! Apache->push_handlers( PerlChildInitHandler => \&child_init );
! }
! sub child_init {
! my ( $r ) = @_;
! my $stash_class = $r->server->dir_config( 'OIStashClass' );
! my $website_dir = $r->server->dir_config( 'OIRootDir' );
! DEBUG && _w( 1, "PerlChildInitHandler being executed for Child ($$) with stash ($stash_class)" );
! my $BASE_CONFIG = OpenInteract::Startup->read_base_config({ website_dir => $website_dir });
! unless ( $BASE_CONFIG ) { die "Cannot create base configuration from ($website_dir)!"; }
! DEBUG && _w( 1, "CHILD INIT: base configuration read in ok." );
! # seed the random number generator per child -- note that we can
! # probably take this out as of mod_perl >= 1.25 but since it
! # doesn't do any harm...
! srand;
! # The big enchilada -- do just about everything here and get back the
! # list of classes that need to be initialized along with the config object.
! # Note that we do not pass the necessary parameters to initialize aliases
! # and to create/initialize the SPOPS classes -- we do that in the child
! # init handler below
! my ( $init_class, $C ) = OpenInteract::Startup->main_initialize({
! base_config => $BASE_CONFIG });
! unless ( $C ) { die "No configuration object returned from initialization!\n"; }
! DEBUG && _w( 1, "CHILD INIT: main initialization completed ok." );
! OpenInteract::Startup->require_module({ class => $C->{session_info}{class} });
! DEBUG && _w( 1, "CHILD INIT: require the session class ok" );
! # Figure out how to do this more cleanly in the near future -- maybe
! # just do it by hand for this special class?
! push @{ $init_class }, 'OpenInteract::PackageRepository';
! # Setup caching info for use in the child init handler below
! my $cache_info = $C->{cache_info}{data};
! my $cache_class = $cache_info->{class};
! my $ipc_cache_class = $C->{cache}{ipc}{class};
! $cache_class->class_initialize({ config => $C }) if ( $cache_info->{use} );
! $ipc_cache_class->class_initialize({ config => $C }) if ( $cache_info->{use_ipc} );
! # Tell OpenInteract::Request to setup aliases if it hasn't already
! my $REQUEST_CLASS = $BASE_CONFIG->{request_class};
! $REQUEST_CLASS->setup_aliases;
! DEBUG && _w( 1, "CHILD INIT: setup \$R aliases ok" );
! # Initialize all the SPOPS object classes
! OpenInteract::Startup->initialize_spops({ config => $C,
! class => $init_class });
! DEBUG && _w( 1, "CHILD INIT: initialize SPOPS classes ok" );
! # Create a list of error handlers for our website
+ eval { OpenInteract::Error::Main->initialize({ config => $C }) };
+ my $err_status = ( $@ ) ? $@ : 'ok';
+ DEBUG && _w( 1, sprintf( "CHILD INIT: %-40s: %-30s","init: Error Dispatcher", $err_status ) );
}
|