webgui/sbin/preload.perl
Drake 936054ba19 Multiple fixes:
- Probably fix "more-geturl-bugs", but hard to verify.
  - Fix "last-modified-problem", approximately.  (Difficult or impossible
    in the general case for externally-retrieved content.)
  - Fix "rss-syndication".
  - Fix unnamed bug where Database caches would try to Storable::freeze
    non-references and thereby crash.
  - Fix "apache-version-component-in-wrong-place".
2006-08-29 16:44:41 +00:00

105 lines
2.5 KiB
Perl

my $webguiRoot;
BEGIN {
$webguiRoot = "/data/WebGUI";
unshift (@INC, $webguiRoot."/lib");
}
$|=1;
use strict;
print "\nStarting WebGUI ".$WebGUI::VERSION."\n";
#----------------------------------------
# Logger
#----------------------------------------
use Log::Log4perl;
Log::Log4perl->init( $webguiRoot."/etc/log.conf" );
#----------------------------------------
# Database connectivity.
#----------------------------------------
#use Apache::DBI (); # Uncomment if you want to enable connection pooling. Not recommended on servers with many sites, or those using db slaves.
use Log::Log4perl ();
use DBI ();
DBI->install_driver("mysql"); # Change to match your database driver.
#----------------------------------------
# WebGUI modules.
#----------------------------------------
use WebGUI ();
use WebGUI::Utility ();
use File::Find ();
my @modules = ();
# these modules should always be skipped
my @excludes = qw(WebGUI::i18n::English::Automated_Information WebGUI::PerformanceProfiler);
open(FILE,"<".$webguiRoot."/sbin/preload.exclude");
while (<FILE>) {
chomp;
push(@excludes,$_);
}
close(FILE);
File::Find::find(\&getWebGUIModules, $webguiRoot."/lib/WebGUI");
foreach my $package (@modules) {
next if (WebGUI::Utility::isIn($package,@excludes));
my $use = "use ".$package." ()";
eval($use);
}
use Apache2::ServerUtil ();
{
# Add WebGUI to Apache version tokens
my $server = Apache2::ServerUtil->server;
my $sub = sub {
$server->add_version_component("WebGUI/".$WebGUI::VERSION);
};
$server->push_handlers(PerlPostConfigHandler => $sub);
}
use APR::Request::Apache2 ();
use Apache2::Cookie ();
#----------------------------------------
# Precache i18n
#----------------------------------------
opendir(DIR,$webguiRoot."/lib/WebGUI/i18n/English");
my @files = readdir(DIR);
closedir(DIR);
foreach my $file (@files) {
if ($file =~ /^(\w+)\.pm$/) {
my $namespace = $1;
my $cmd = "\$WebGUI::i18n::English::".$namespace."::I18N";
my $data = eval($cmd);
$WebGUI::International::i18nCache{English}{$namespace} = $data;
}
}
#----------------------------------------
# Preload all site configs.
#----------------------------------------
WebGUI::Config->loadAllConfigs($webguiRoot);
print "WebGUI Started!\n";
#----------------------------------------
sub getWebGUIModules {
my $filename = $File::Find::dir."/".$_;
return unless $filename =~ m/\.pm$/;
my $package = $filename;
$package =~ s/^$webguiRoot\/lib\/(.*)\.pm$/$1/;
$package =~ s/\//::/g;
push(@modules,$package);
}
1;