X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=htetc%2Fhandler.pl;h=2fe5d376e5aa809386bab34302a7ab4c20290e69;hp=cea366134f8d734c4c93f10d46f4c6025715b690;hb=949a80c148a8bbeeeec54c5a0be5d73b292423a5;hpb=22a1feb55c4bb705064a04646ff5c321b8112ce1 diff --git a/htetc/handler.pl b/htetc/handler.pl index cea366134..2fe5d376e 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -5,6 +5,34 @@ package HTML::Mason; use strict; use warnings; use FS::Mason qw( mason_interps ); +use FS::Trace; +use FS::access_user_log; +use FS::Conf; + +$FS::Conf::conf_cache_enabled = 1; # enable FS::Conf caching for performance + +# Preload to share in mod_perl parent for performance +use FS::UID qw(load_schema); +load_schema(); +use FS::Record qw(fk_methods_init); +fk_methods_init; + +if ( %%%RT_ENABLED%%% ) { + + require RT; + + $> = scalar(getpwnam('freeside')); + + RT::LoadConfig(); + RT::Init(); + + # disconnect DB before fork: + # (avoid 'prepared statement "dbdpg_p\d+_\d+" already exists' errors?) + $RT::Handle->dbh(undef); + undef $RT::Handle; + + $> = $<; +} #use vars qw($r); @@ -38,6 +66,10 @@ sub handler #($r) = @_; my $r = shift; + my $start_time = time; + + FS::Trace->log('protecting fds'); + #from rt/bin/webmux.pl(.in) if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'} && $ENV{'MOD_PERL_API_VERSION'} >= 2 @@ -63,6 +95,8 @@ sub handler ###Module::Refresh->refresh;### + FS::Trace->log('setting content_type / headers'); + $r->content_type('text/html; charset=utf-8'); #$r->content_type('text/html; charset=iso-8859-1'); #eorar @@ -76,23 +110,29 @@ sub handler if ( $r->filename =~ /\/rt\// ) { #RT + FS::Trace->log('handling RT file'); + # We don't need to handle non-text, non-xml items return -1 if defined( $r->content_type ) && $r->content_type !~ m!(^text/|\bxml\b)!io; - local $SIG{__WARN__}; local $SIG{__DIE__}; + FS::Trace->log('initializing RT'); my_rt_init(); + FS::Trace->log('setting RT interpreter'); $ah->interp($rt_interp); } else { + FS::Trace->log('handling Freeside file'); + local $SIG{__WARN__}; local $SIG{__DIE__}; + FS::Trace->log('initializing RT'); my_rt_init(); #we don't want the RT error handlers under FS @@ -102,10 +142,12 @@ sub handler undef($SIG{__DIE__}) if defined($SIG{__DIE__} ); } + FS::Trace->log('setting Freeside interpreter'); $ah->interp($fs_interp); } + FS::Trace->log('handling request'); my %session; my $status; eval { $status = $ah->handle_request($r); }; @@ -125,22 +167,24 @@ sub handler # ); # } + FS::access_user_log->insert_new_path( $r->filename, time-$start_time ); + + FS::Trace->log('done'); + + FS::Trace->dumpfile( "%%%FREESIDE_EXPORT%%%/profile/$$.".time, + FS::Trace->total. ' '. $r->filename + ) + if FS::Trace->total > 5; #10? + + FS::Trace->reset; + $status; } -my $rt_initialized = 0; - sub my_rt_init { return unless $RT::VERSION; - - if ( $rt_initialized ) { - RT::ConnectToDatabase(); - RT::InitSignalHandlers(); - } else { - RT::LoadConfig(); - RT::Init(); - $rt_initialized++; - } + RT::ConnectToDatabase(); + RT::InitSignalHandlers(); } 1;