]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
no bug - add USE_NYTPROF to PerlPassEnv (#395)
authorDylan William Hardison <dylan@hardison.net>
Fri, 16 Feb 2018 01:49:33 +0000 (20:49 -0500)
committerGitHub <noreply@github.com>
Fri, 16 Feb 2018 01:49:33 +0000 (20:49 -0500)
Bugzilla/Install/Filesystem.pm
README.rst
mod_perl.pl

index 89a1e5d93af28aa0a5973666efeb9bfc06494514..e1e9a47d7d5c7518fc601040dae4b7198ea3bfdf 100644 (file)
@@ -102,13 +102,16 @@ use constant INDEX_HTML => <<'EOT';
 </html>
 EOT
 
-sub HTTPD_ENV_CONF {
+use constant HTTPD_ENV => qw(
+    LOCALCONFIG_ENV
+    BUGZILLA_UNSAFE_AUTH_DELEGATION
+    USE_NYTPROF
+    NYTPROF_DIR
+);
 
-    return join( "\n",
-      "PerlPassEnv LOCALCONFIG_ENV",
-      "PerlPassEnv BUGZILLA_UNSAFE_AUTH_DELEGATION",
-      map { "PerlPassEnv " . $_ } ENV_KEYS
-    ) . "\n";
+sub HTTPD_ENV_CONF {
+    my @env = (ENV_KEYS, HTTPD_ENV);
+    return join( "\n", map { "PerlPassEnv " . $_ } @env ) . "\n";
 }
 
 ###############
@@ -304,7 +307,7 @@ sub FILESYSTEM {
          js                    => { files => WS_SERVE,
                                      dirs => DIR_WS_SERVE },
          static                => { files => WS_SERVE,
-                                     dirs => DIR_WS_SERVE },                                     
+                                     dirs => DIR_WS_SERVE },
          $skinsdir             => { files => WS_SERVE,
                                      dirs => DIR_WS_SERVE },
          'docs/*/html'         => { files => WS_SERVE,
index 6c150dba4461d13b9e83161a933043b995c53efa..555d5f951bbdce1cbb92dbc020f59d183e649919 100644 (file)
@@ -282,6 +282,18 @@ HTTPD_MaxRequestsPerChild
   will die. If MaxRequestsPerChild is 0, then the process will never expire.
   Default: 4000
 
+USE_NYTPROF
+  Write `Devel::NYTProf`_ profiles out for each requests.
+  These will be named /app/data/nytprof.$host.$script.$n.$pid, where $host is
+  the hostname of the container, script is the name of the script (without
+  extension), $n is a number starting from 1 and incrementing for each
+  request to the worker process, and $pid is the worker process id.
+
+NYTPROF_DIR
+  Alternative location to store profiles from the above option.
+
+.. _`Devel::NYTProf`: https://metacpan.org/pod/Devel::NYTProf
+
 Persistent Data Volume
 ----------------------
 
index f94b7f7d42b6ba90186d58c1380cb7a08ab2a39f..09fd8085045c387205882961ce8b8c5f8ebfd493 100644 (file)
@@ -23,8 +23,14 @@ BEGIN {
 }
 
 use Bugzilla::ModPerl::StartupFix;
+use Taint::Util qw(untaint);
 
 use constant USE_NYTPROF => !! $ENV{USE_NYTPROF};
+use constant NYTPROF_DIR => do {
+    my $dir = $ENV{NYTPROF_DIR};
+    untaint($dir);
+    $dir;
+};
 BEGIN {
     if (USE_NYTPROF) {
         $ENV{NYTPROF} = "savesrc=0:start=no:addpid=1";
@@ -132,6 +138,7 @@ use base qw(ModPerl::Registry);
 use Bugzilla;
 use Bugzilla::Constants qw(USAGE_MODE_REST bz_locations);
 use Time::HiRes;
+use Sys::Hostname;
 
 sub handler : method {
     my $class = shift;
@@ -150,9 +157,11 @@ sub handler : method {
 
     if (Bugzilla::ModPerl::USE_NYTPROF) {
         state $count = {};
+        state $dir  = Bugzilla::ModPerl::NYTPROF_DIR // bz_locations()->{datadir};
+        state $host = (split(/\./, hostname()))[0];
         my $script = File::Basename::basename($ENV{SCRIPT_FILENAME});
         $script =~ s/\.cgi$//;
-        my $file = bz_locations()->{datadir} . "/nytprof.$script." . ++$count->{$$};
+        my $file = $dir . "/nytprof.$host.$script." . ++$count->{$$};
         DB::enable_profile($file);
     }
     Bugzilla::init_page();