Added pidfile option to FastCGI server
Andy Grundman [Tue, 15 Nov 2005 19:32:50 +0000 (19:32 +0000)]
Changes
lib/Catalyst/Engine/FastCGI.pm
lib/Catalyst/Helper.pm

diff --git a/Changes b/Changes
index bc31240..6a76cc3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -6,6 +6,7 @@ This file documents the revision history for Perl extension Catalyst.
         - Updated benchmarking to work with detach
         - Fixed dispatcher, so $c->req->action(undef) works again
         - Updated Catalyst::Test to use HTTP::Request::AsCGI
+        - Added -pidfile to external FastCGI server.
 
 5.55    2005-11-15 12:55:00
         - Fixed multiple cookie handling
index 469d5dc..1697558 100644 (file)
@@ -37,6 +37,7 @@ Options may also be specified;
                   interrupted by Ctrl+C
   nproc           Specify a number of processes for
                   FCGI::ProcManager
+  pidfile         Specify a filename for the pid file
 
 =cut
 
@@ -70,11 +71,18 @@ sub run {
       );
 
     my $proc_manager;
-
-    if ( $listen and ( $options->{nproc} || 1 ) > 1 ) {
+    
+    if ( $listen ) {
         require FCGI::ProcManager;
-        $proc_manager =
-          FCGI::ProcManager->new( { n_processes => $options->{nproc} } );
+        $options->{nproc} ||= 1;
+        
+        $proc_manager
+            = FCGI::ProcManager->new( { n_processes => $options->{nproc} } );
+          
+        if ( $options->{pidfile} ) {
+            $proc_manager->pm_write_pid_file( $options->{pidfile} );
+        }
+        
         $proc_manager->pm_manage();
     }
 
index d63c7c1..89ee894 100644 (file)
@@ -690,17 +690,23 @@ use lib "$FindBin::Bin/../lib";
 use [% name %];
 
 my $help = 0;
-my ( $listen, $nproc );
+my ( $listen, $nproc, $pidfile );
  
 GetOptions(
-    'help|?'     => \$help,
-    'listen|l=s' => \$listen,
-    'nproc|n=i'  => \$nproc,
+    'help|?'      => \$help,
+    'listen|l=s'  => \$listen,
+    'nproc|n=i'   => \$nproc,
+    'pidfile|p=s' => \$pidfile,
 );
 
 pod2usage(1) if $help;
 
-[% name %]->run( $listen, { nproc => $nproc } );
+[% name %]->run( 
+    $listen, 
+    {   nproc   => $nproc,
+        pidfile => $pidfile, 
+    }
+);
 
 1;