Item14532: Allow process name override for FCGI task.
Priority: Enhancement
Current State: Closed
Released In: 2.1.5
Target Release: patch
The process table always shows a fixed name for the fcgi handlers regardless of the name of the init script.
www-data 1554 0.0 0.2 79928 2112 ? S Nov19 0:00 foswiki-fcgi-pm
www-data 1557 0.0 0.1 79928 1212 ? Ss Nov19 0:00 \_ foswiki-fcgi
www-data 1558 0.0 0.1 79928 1212 ? Ss Nov19 0:00 \_ foswiki-fcgi
www-data 1559 0.0 0.1 79928 1212 ? Ss Nov19 0:00 \_ foswiki-fcgi
www-data 3573 0.0 2.8 80116 29408 ? S 09:15 0:00 foswiki-fcgi-pm
www-data 3574 0.0 2.8 80116 28556 ? Ss 09:15 0:00 \_ foswiki-fcgi
www-data 3575 0.0 2.8 80116 28604 ? Ss 09:15 0:00 \_ foswiki-fcgi
www-data 3576 0.0 2.8 80116 28476 ? Ss 09:15 0:00 \_ foswiki-fcgi
Suggest the following enhancements:
- Add a parameter to the foswiki.fcgi script -
-N | pname
- Change init script to pass
-N ${NAME}
as an argument
- Change
lib/Foswiki/Engine/FastCGI.pm
to set the name from the new argument
Patch
diff --git a/FastCGIEngineContrib/bin/foswiki.fcgi b/FastCGIEngineContrib/bin/foswiki.fcgi
index c39f11a..8691bcb 100755
--- a/FastCGIEngineContrib/bin/foswiki.fcgi
+++ b/FastCGIEngineContrib/bin/foswiki.fcgi
@@ -44,7 +44,7 @@ our ($dir) = Cwd::cwd() =~ /^(.*)$/;
my @argv = @ARGV;
-my ( $listen, $nproc, $max, $size, $check, $pidfile, $manager, $detach, $help, $quiet );
+my ( $listen, $nproc, $max, $size, $check, $pidfile, $manager, $detach, $help, $quiet, $pname );
GetOptions(
'listen|l=s' => \$listen,
'nproc|n=i' => \$nproc,
@@ -56,6 +56,7 @@ GetOptions(
'daemon|d' => \$detach,
'help|?' => \$help,
'quiet|q' => \$quiet,
+ 'pname|N=s' => \$pname,
);
pod2usage(1) if $help;
@@ -79,6 +80,7 @@ $Foswiki::engine->run(
max => $max,
size => $size,
check => $check,
+ pname => $pname,
}
);
@@ -99,6 +101,7 @@ foswiki.fcgi [options]
-d --daemon Detach from terminal and keeps running as a daemon
-q --quiet Disable notification messages
-? --help Display this help and exits
+ -N --pname Process name to display in ps output
Note:
FCGI manager class defaults to Foswiki::Engine::FastCGI::ProcManager, a
diff --git a/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm b/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm
index 3ecf480..bc58bd1 100644
--- a/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm
+++ b/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI.pm
@@ -90,6 +90,7 @@ sub run {
n_processes => $args->{nproc},
pid_fname => $args->{pidfile},
quiet => $args->{quiet},
+ pm_title => ($args->{pname} || 'foswiki') . '-fcgi-pm',
max_requests =>
( defined $args->{max} ? $args->{max} : $maxRequests ),
@@ -103,6 +104,7 @@ sub run {
);
$manager->pm_manage();
+ $manager->pm_change_process_name( ($args->{pname} || 'foswiki') . '-fcgi' );
}
else { # No ProcManager
diff --git a/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI/ProcManager.pm b/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI/ProcManager.pm
index dd91019..94beeb6 100644
--- a/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI/ProcManager.pm
+++ b/FastCGIEngineContrib/lib/Foswiki/Engine/FastCGI/ProcManager.pm
@@ -64,8 +64,6 @@ sub pm_notify {
sub pm_change_process_name {
my ($this,$name) = @_;
-
- $name =~ s/perl/foswiki/g;
$0 = $name;
}
Slotting this for 2.1.5. It's a very minor enhancement.
--
GeorgeClark - 20 Nov 2017
Whoops -
GetOptions is not case sensitive so -N for name collides with -n for number of processes. Changing to -a for nAme,.
--
GeorgeClark - 03 Dec 2017