[Catalyst] FastCGI stuff

Mark Ethan Trostler mark at zzo.com
Tue Aug 8 01:47:19 CEST 2006


Am I on crack or do I really have to make the below changes???:

- My perl 5.8 needs a LENGTH to syswrite.

- ProcManager doesn't like daemonized processes it seems & the code
currently forces the use of one - although the docs for myapp_fastcgi.pl
seems to imply I can just give a -M '' to have no proc manager, but the
code in FastCGI.pm doesn't allow it.
Later in the FastCGI.pm code it checks 'if ($options->{manager}' - which
is always gonna be true unless I comment out that '||=' carnage.

- Finally just 'cuz I a daemon I still want a PID file!!

thanks!
   Mark


--- FastCGI.pm	Mon Aug  7 16:33:15 2006
+++ hack/FastCGI.pm	Mon Aug  7 16:33:00 2006
@@ -74,7 +74,7 @@ sub run {
      my $proc_manager;

      if ($listen) {
-        $options->{manager} ||= "FCGI::ProcManager";
+        # This forces the use of a ProcManager when uncommented
+        #  which doesn't seem to like daemonized processes
+        #$options->{manager} ||= "FCGI::ProcManager";
          $options->{nproc}   ||= 1;

          $self->daemon_fork() if $options->{detach};
@@ -95,6 +95,11 @@ sub run {
              $proc_manager->pm_manage();
          }
          elsif ( $options->{detach} ) {
+            if (my $pid_fname = $options->{pidfile}) {
+                open(P, ">$pid_fname");
+                print P "$$\n";
+                close(P);
+            }
              $self->daemon_detach();
          }
      }
@@ -120,7 +125,7 @@ sub write {

      # FastCGI does not stream data properly if using 'print $handle',
      # but a syswrite appears to work properly.
-    *STDOUT->syswrite($buffer);
+    *STDOUT->syswrite($buffer, length($buffer));
  }

  =head2 $self->daemon_fork()




More information about the Catalyst mailing list