LJSUP-17669: Login.bml form refactoring
[livejournal.git] / cgi-bin / modperl.pl
blob5089ec83654c093fa1ef78345835439495fbdb6f
1 #!/usr/bin/perl
4 package LJ::ModPerl;
5 use strict;
6 use lib "$ENV{LJHOME}/cgi-bin";
8 # this code prevents the XS version of Params::Classify from loading
9 # we do this because the combination of Params::Classify, IpMap, and
10 # mod_perl seems to segfault after apache forks
11 BEGIN {
12 require XSLoader;
13 my $old_load = \&XSLoader::load;
14 local *XSLoader::load = sub {
15 my @args = @_;
16 my ($pkgname) = @args;
17 die if $pkgname eq 'Params::Classify';
18 $old_load->(@args);
20 eval { require Params::Classify };
23 use LJ::Request;
25 $LJ::UPTIME = time();
27 # Image::Size wants to pull in Image::Magick. Let's not let it during
28 # the init process.
29 my $still_loading = 1;
30 unshift @INC, sub {
31 my $f = $_[1];
32 return undef unless $still_loading;
33 return undef unless $f eq "Image/Magick.pm";
34 die "Will not start with Image/Magick.pm"; # makes the require fail, which Image::Size traps
37 # pull in libraries and do per-start initialization once.
38 require "modperl_subs.pl";
40 $still_loading = 0;
42 # do per-restart initialization
43 LJ::ModPerl::setup_restart();
45 # delete itself from %INC to make sure this file is run again
46 # when apache is restarted
47 delete $INC{"$ENV{'LJHOME'}/cgi-bin/modperl.pl"};
49 # remember modtime of all loaded libraries
50 %LJ::LIB_MOD_TIME = ();
51 while (my ($k, $file) = each %INC) {
52 next if $LJ::LIB_MOD_TIME{$file};
53 next unless $file =~ m!^\Q$LJ::HOME\E!;
54 my $mod = (stat($file))[9];
55 $LJ::LIB_MOD_TIME{$file} = $mod;
58 # compatibility with old location of LJ::email_check:
59 *BMLCodeBlock::check_email = \&LJ::check_email;
62 ## Signal handler for debugging infinite loops
63 ## Taken from: http://perl.apache.org/docs/1.0/guide/debug.html
64 ## Usage: kill -USR2 <pid>
66 use Carp();
67 $SIG{'USR2'} = sub { Carp::confess("caught SIGUSR2!"); };
72 use Sys::Hostname;
73 $LJ::HARDWARE_SERVER_NAME = hostname();
75 LJ::Lang::init_bml();