Added a --title parameter to fastcgi script, sets process title for FCGI::ProcManager
Eskild Hustvedt [Wed, 3 Nov 2010 15:09:37 +0000 (15:09 +0000)]
lib/Catalyst/Engine/FastCGI.pm
lib/Catalyst/Script/FastCGI.pm
t/aggregate/unit_core_script_fastcgi.t

index 96b75df..ec1aee3 100644 (file)
@@ -113,6 +113,7 @@ sub run {
     if ($listen) {
         $options->{manager} ||= "FCGI::ProcManager";
         $options->{nproc}   ||= 1;
+        $options->{title}   ||= "perl-fcgi-pm [$class]";
 
         $self->daemon_fork() if $options->{detach};
 
@@ -123,6 +124,7 @@ sub run {
                 {
                     n_processes => $options->{nproc},
                     pid_fname   => $options->{pidfile},
+                    pm_title => $options->{title},
                 }
             );
 
index 60b4133..b494d48 100644 (file)
@@ -55,6 +55,14 @@ has nproc => (
     documentation => 'Specify a number of child processes',
 );
 
+has title => (
+    traits        => [qw(Getopt)],
+    cmd_aliases   => 't',
+    isa           => Str,
+    is            => 'ro',
+    documentation => 'Set the process title',
+);
+
 sub _application_args {
     my ($self) = shift;
     return (
@@ -65,6 +73,7 @@ sub _application_args {
             manager => $self->manager,
             detach  => $self->daemon,
             keep_stderr => $self->keeperr,
+            title => $self->title,
         }
     );
 }
@@ -96,6 +105,7 @@ Catalyst::Script::FastCGI - The FastCGI Catalyst Script
                   or empty string to disable
    -e --keeperr   send error messages to STDOUT, not
                   to the webserver
+   -t --title     set the process title
 
 =head1 DESCRIPTION
 
index b5d3ea4..5f0b5dc 100644 (file)
@@ -39,6 +39,10 @@ testOption( [ qw/-e/ ], [undef, opthash(keep_stderr => 1)] );
 testOption( [ qw/--nproc 6/ ], [undef, opthash(nproc => 6)] );
 testOption( [ qw/--n 6/ ], [undef, opthash(nproc => 6)] );
 
+# title
+testOption( [ qw/--title foo/ ], [undef, opthash(title => 'foo')] );
+testOption( [ qw/-t foo/ ], [undef, opthash(title => 'foo')] );
+
 done_testing;
 
 sub testOption {
@@ -62,6 +66,7 @@ sub opthash {
         detach => undef,
         nproc => undef,
         manager => undef,
+        title => undef,
         @_,
     };
 }