X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=htetc%2Fhandler.pl;h=2fe5d376e5aa809386bab34302a7ab4c20290e69;hp=77b93463fedbe25bbf365dea3922f32dc6d0ff25;hb=29d80a8582103ead0b5910391cabc45cb85fa836;hpb=07d63243b070962b8fcf8e6b59128ccf1305f8f8 diff --git a/htetc/handler.pl b/htetc/handler.pl index 77b93463f..2fe5d376e 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -6,6 +6,33 @@ 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); @@ -39,6 +66,8 @@ sub handler #($r) = @_; my $r = shift; + my $start_time = time; + FS::Trace->log('protecting fds'); #from rt/bin/webmux.pl(.in) @@ -87,7 +116,6 @@ sub handler return -1 if defined( $r->content_type ) && $r->content_type !~ m!(^text/|\bxml\b)!io; - local $SIG{__WARN__}; local $SIG{__DIE__}; @@ -139,9 +167,13 @@ 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, $r->filename) + FS::Trace->dumpfile( "%%%FREESIDE_EXPORT%%%/profile/$$.".time, + FS::Trace->total. ' '. $r->filename + ) if FS::Trace->total > 5; #10? FS::Trace->reset; @@ -149,19 +181,10 @@ sub handler $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;