X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=dispatcher.fpl;h=9b7c98b7d1302088ed1f4ea6f35a9fdf88ee477f;hb=HEAD;hp=5e384ce68c3639396569e7fa02db8001b28c3979;hpb=a4bd0c541580678d108c383ab268f233ce44b25b;p=kivitendo-erp.git diff --git a/dispatcher.fpl b/dispatcher.fpl index 5e384ce68..9b7c98b7d 100755 --- a/dispatcher.fpl +++ b/dispatcher.fpl @@ -2,69 +2,22 @@ use strict; -use FCGI; -use IO::File; -use SL::Dispatcher; -use SL::FCGIFixes; -use SL::LXDebug; - -sub _parse_number_with_unit { - my ($number) = @_; - - return undef unless defined $number; - return $number unless $number =~ m{^ \s* (\d+) \s* ([kmg])b \s* $}xi; - - my %factors = (K => 1024, M => 1024 * 1024, G => 1024 * 1024 * 1024); +BEGIN { + use FindBin; - return $1 * $factors{uc $2}; + unshift(@INC, $FindBin::Bin . '/modules/override'); # Use our own versions of various modules (e.g. YAML). + push (@INC, $FindBin::Bin); # '.' will be removed from @INC soon. + push (@INC, $FindBin::Bin . '/modules/fallback'); # Only use our own versions of modules if there's no system version. } -sub _memory_usage_is_too_high { - return undef unless $::lx_office_conf{system}; - - my %limits = ( - rss => _parse_number_with_unit($::lx_office_conf{system}->{memory_limit_rss}), - size => _parse_number_with_unit($::lx_office_conf{system}->{memory_limit_vsz}), - ); - - # $::lxdebug->dump(0, "limits", \%limits); - - return undef unless $limits{rss} || $limits{vsz}; - - my %usage; - - my $in = IO::File->new("/proc/$$/status", "r") or return undef; - - while (<$in>) { - chomp; - $usage{lc $1} = _parse_number_with_unit($2) if m{^ vm(rss|size): \s* (\d+ \s* [kmg]b) \s* $}ix; - } - - $in->close; - - # $::lxdebug->dump(0, "usage", \%usage); - - foreach my $type (keys %limits) { - next if !$limits{$type}; - next if $limits{$type} >= ($usage{$type} // 0); - - $::lxdebug->message(LXDebug::WARN(), "Exiting due to memory size limit reached for type '${type}': limit " . $limits{$type} . " bytes, usage " . $usage{$type} . " bytes"); - - return 1; - } - - return 0; -} +use SL::Dispatcher; +use SL::FCGIFixes; +use SL::LXDebug; our $dispatcher = SL::Dispatcher->new('FastCGI'); $dispatcher->pre_startup_setup; SL::FCGIFixes::apply_fixes(); $dispatcher->pre_startup_checks; - -my $request = FCGI::Request(); -while ($request->Accept() >= 0) { - $dispatcher->handle_request($request); - exit if _memory_usage_is_too_high(); -} +$dispatcher->handle_all_requests; 1;