[Catalyst-commits] r11880 - in Catalyst-Runtime/5.80/branches/better_scripts: . lib/Catalyst/Script t

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Wed Nov 18 00:51:30 GMT 2009


Author: t0m
Date: 2009-11-18 00:51:29 +0000 (Wed, 18 Nov 2009)
New Revision: 11880

Modified:
   Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts
   Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/FastCGI.pm
   Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm
   Catalyst-Runtime/5.80/branches/better_scripts/t/unit_core_script_server.t
Log:
Beat somewhat into shape by comparing the old and new docs. Need to write basic tests for the other scripts.

Modified: Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts	2009-11-17 23:00:32 UTC (rev 11879)
+++ Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts	2009-11-18 00:51:29 UTC (rev 11880)
@@ -1,6 +1,6 @@
-* Fix the fucking help to be consistent again!
 * Documentation
-* Proper test of all the options on all the scripts
+  * Catalyst::ScriptRole needs proper docs
+* $ARGV[0] has slipped to $ARGV[1] in ::Test
 * ScriptRunner tests for MyApp::Script::DoesNotCompile
-
-* Tests for Scripts / Role
+* Tests for ScriptRole
+* Sort out help discrepancy between the help you get if you --help, and the help you get if you mess an option up.

Modified: Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/FastCGI.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/FastCGI.pm	2009-11-17 23:00:32 UTC (rev 11879)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/FastCGI.pm	2009-11-18 00:51:29 UTC (rev 11880)
@@ -10,7 +10,7 @@
 has listen => (
     traits => [qw(Getopt)],
     cmd_aliases => 'l',
-    isa => Int,
+    isa => Str,
     is => 'ro',
     documentation => 'Specify a listening port/socket',
 );
@@ -28,20 +28,20 @@
     isa => Bool,   
     is => 'ro', 
     cmd_aliases => 'd', 
-    documentation => 'Daemonize',
+    documentation => 'Daemonize (go into the background)',
 );
 
 has manager => (
     traits => [qw(Getopt)],
     isa => Str,    
     is => 'ro',
-    cmd_aliases => 'm',
-    documentation => 'Use a different FastCGI manager', # FIXME
+    cmd_aliases => 'M',
+    documentation => 'Use a different FastCGI process manager class',
 );
 
-has keep_stderr => (
+has keeperr => (
     traits => [qw(Getopt)],
-    cmd_aliases => 'std', 
+    cmd_aliases => 'e', 
     isa => Bool,   
     is => 'ro',  
     documentation => 'Log STDERR',
@@ -49,10 +49,10 @@
 
 has nproc => (
     traits => [qw(Getopt)],
-    cmd_aliases => 'np',  
+    cmd_aliases => 'n',  
     isa => Int,
     is => 'ro',  
-    documentation => 'Specify an nproc', # FIXME
+    documentation => 'Specify a number of child processes',
 );
 
 has detach => (
@@ -72,7 +72,7 @@
             pidfile => $self->pidfile,
             manager => $self->manager,
             detach  => $self->detach,
-            keep_stderr => $self->keep_stderr,
+            keep_stderr => $self->keeperr,
         }
     );
 }
@@ -85,11 +85,29 @@
 
 =head1 SYNOPSIS
 
-See L<Catalyst>.
+  myapp_fastcgi.pl [options]
 
+ Options:
+   -? -help      display this help and exits
+   -l -listen    Socket path to listen on
+                 (defaults to standard input)
+                 can be HOST:PORT, :PORT or a
+                 filesystem path
+   -n -nproc     specify number of processes to keep
+                 to serve requests (defaults to 1,
+                 requires -listen)
+   -p -pidfile   specify filename for pid file
+                 (requires -listen)
+   -d -daemon    daemonize (requires -listen)
+   -M -manager   specify alternate process manager
+                 (FCGI::ProcManager sub-class)
+                 or empty string to disable
+   -e -keeperr   send error messages to STDOUT, not
+                 to the webserver
+
 =head1 DESCRIPTION
 
-FIXME
+Run a Catalyst application as fastcgi.
 
 =head1 AUTHORS
 

Modified: Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm	2009-11-17 23:00:32 UTC (rev 11879)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Server.pm	2009-11-18 00:51:29 UTC (rev 11880)
@@ -6,7 +6,6 @@
 }
 
 use Moose;
-use Catalyst::Restarter;
 use MooseX::Types::Moose qw/ArrayRef Str Bool Int/;
 use namespace::autoclean;
 
@@ -22,10 +21,11 @@
 
 has host => (
     traits => [qw(Getopt)],
+    cmd_aliases => 'h',
     isa => Str,
     is => 'ro',
     default => 'localhost',
-    documentation => 'Specify a host for the server to run on',
+    documentation => 'Specify an IP on this host for the server to bind to',
 );
 
 has fork => (
@@ -33,7 +33,8 @@
     cmd_aliases => 'f',
     isa => Bool,
     is => 'ro',
-    documentation => 'Fork the server',
+    default => 0,
+    documentation => 'Fork the server to be able to serve multiple requests at once',
 );
 
 has port => (
@@ -42,7 +43,7 @@
     isa => Int,
     is => 'ro',
     default => 3000,
-    documentation => 'Specify a different listening port',
+    documentation => 'Specify a different listening port (to the default port 3000)',
 );
 
 has pidfile => (
@@ -58,8 +59,8 @@
     cmd_aliases => 'k',
     isa => Bool,
     is => 'ro',
-    documentation => 'Server keepalive',
-
+    default => 0,
+    documentation => 'Support keepalive',
 );
 
 has background => (
@@ -67,6 +68,7 @@
     cmd_aliases => 'bg',
     isa => Bool,
     is => 'ro',
+    default => 0,
     documentation => 'Run in the background',
 );
 
@@ -75,7 +77,8 @@
     cmd_aliases => 'r',
     isa => Bool,
     is => 'ro',
-    documentation => 'use Catalyst::Restarter to detect code changes',
+    default => 0,
+    documentation => 'use Catalyst::Restarter to detect code changes and restart the application',
 );
 
 has restart_directory => (
@@ -83,26 +86,26 @@
     cmd_aliases => 'rdir',
     isa => ArrayRef[Str],
     is  => 'ro',
+    documentation => 'Restarter directory to watch',
     predicate => '_has_restart_directory',
-    documentation => 'Restarter directory to watch',
 );
 
 has restart_delay => (
     traits => [qw(Getopt)],
-    cmd_aliases => 'rdel',
+    cmd_aliases => 'rd',
     isa => Int,
     is => 'ro',
+    documentation => 'Set a restart delay',
     predicate => '_has_restart_delay',
-    documentation => 'Set a restart delay',
 );
 
 has restart_regex => (
     traits => [qw(Getopt)],
-    cmd_aliases => 'rxp',
+    cmd_aliases => 'rr',
     isa => Str,
     is => 'ro',
+    documentation => 'Restart regex',
     predicate => '_has_restart_regex',
-    documentation => 'Restart regex',
 );
 
 has follow_symlinks => (
@@ -110,37 +113,35 @@
     cmd_aliases => 'sym',
     isa => Bool,
     is => 'ro',
-    predicate => '_has_follow_symlinks',
+    default => 0,
     documentation => 'Follow symbolic links',
-
 );
 
 sub run {
     my ($self) = shift;
 
-    if ( $self->debug ) {
-        $ENV{CATALYST_DEBUG} = 1;
-    }
+    local $ENV{CATALYST_DEBUG} = 1
+        if $self->debug;
 
-    # If we load this here, then in the case of a restarter, it does not
-    # need to be reloaded for each restart.
-    require Catalyst;
-
-    # If this isn't done, then the Catalyst::Devel tests for the restarter
-    # fail.
-    $| = 1 if $ENV{HARNESS_ACTIVE};
-
     if ( $self->restart ) {
         die "Cannot run in the background and also watch for changed files.\n"
             if $self->background;
 
+        # If we load this here, then in the case of a restarter, it does not
+        # need to be reloaded for each restart.
+        require Catalyst;
+
+        # If this isn't done, then the Catalyst::Devel tests for the restarter
+        # fail.
+        $| = 1 if $ENV{HARNESS_ACTIVE};
+
         require Catalyst::Restarter;
 
         my $subclass = Catalyst::Restarter->pick_subclass;
 
         my %args;
         $args{follow_symlinks} = $self->follow_symlinks
-            if $self->_has_follow_symlinks;
+            if $self->follow_symlinks;
         $args{directories}     = $self->restart_directory
             if $self->_has_restart_directory;
         $args{sleep_interval}  = $self->restart_delay

Modified: Catalyst-Runtime/5.80/branches/better_scripts/t/unit_core_script_server.t
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/t/unit_core_script_server.t	2009-11-17 23:00:32 UTC (rev 11879)
+++ Catalyst-Runtime/5.80/branches/better_scripts/t/unit_core_script_server.t	2009-11-18 00:51:29 UTC (rev 11880)
@@ -52,7 +52,7 @@
 $testopts = opthash();
 $testopts->{background} = 1;
 testOption( [ qw/--background/ ], ['3000', 'localhost', $testopts] );
-    
+
 # Restart stuff requires a threaded perl, apparently.
 # restart        -r -restart --restart     -R --restart
 # restart dly    -rd -restartdelay         --rdel --restart_delay
@@ -81,9 +81,9 @@
 # Returns the hash expected when no flags are passed
 sub opthash {
     return { 'pidfile' => undef,
-             'fork' => undef,
-             'follow_symlinks' => undef,
-             'background' => undef,
-             'keepalive' => undef,
+             'fork' => 0,
+             'follow_symlinks' => 0,
+             'background' => 0,
+             'keepalive' => 0,
          }
 }




More information about the Catalyst-commits mailing list