Skip to content

Commit

Permalink
better command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 16, 2013
1 parent 2193818 commit a21896e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
73 changes: 37 additions & 36 deletions lib/Mojolicious/Command/prefork.pm
Expand Up @@ -10,30 +10,31 @@ has usage => <<"EOF";
usage: $0 prefork [OPTIONS]
These options are available:
-B <seconds> Set heartbeat interval, defaults to 5.
-b, --backlog <size> Set listen backlog size, defaults to
SOMAXCONN.
-c, --clients <number> Set maximum number of concurrent clients,
defaults to 1000.
-f <path> Set path to lock file, defaults to a random
file.
-G, --graceful <seconds> Set graceful timeout, defaults to 20.
-g, --group <name> Set group name for process.
-H <seconds> Set heartbeat timeout, defaults to 20.
-i, --inactivity <seconds> Set inactivity timeout, defaults to the value
of MOJO_INACTIVITY_TIMEOUT or 15.
-L <seconds> Set lock timeout, defaults to 0.5.
-l, --listen <location> Set one or more locations you want to listen
on, defaults to the value of MOJO_LISTEN or
"http://*:3000".
-P, --pid <path> Set path to process id file, defaults to a
random file.
-p, --proxy Activate reverse proxy support, defaults to
the value of MOJO_REVERSE_PROXY.
-r, --requests <number> Set maximum number of requests per keep-alive
connection, defaults to 25.
-u, --user <name> Set username for process.
-w, --workers <number> Set number of worker processes.
-b, --backlog <size> Set listen backlog size, defaults to
SOMAXCONN.
-c, --clients <number> Set maximum number of concurrent
clients, defaults to 1000.
-G, --graceful-timeout <seconds> Set graceful timeout, defaults to 20.
-g, --group <name> Set group name for process.
--heartbeat-interval <seconds> Set heartbeat interval, defaults to 5.
-H, --heartbeat-timeout <seconds> Set heartbeat timeout, defaults to 20.
-i, --inactivity <seconds> Set inactivity timeout, defaults to the
value of MOJO_INACTIVITY_TIMEOUT or 15.
--lock-file <path> Set path to lock file, defaults to a
random file.
-L, --lock-timeout <seconds> Set lock timeout, defaults to 0.5.
-l, --listen <location> Set one or more locations you want to
listen on, defaults to the value of
MOJO_LISTEN or "http://*:3000".
-P, --pid-file <path> Set path to process id file, defaults
to a random file.
-p, --proxy Activate reverse proxy support,
defaults to the value of
MOJO_REVERSE_PROXY.
-r, --requests <number> Set maximum number of requests per
keep-alive connection, defaults to 25.
-u, --user <name> Set username for process.
-w, --workers <number> Set number of worker processes.
EOF

sub run {
Expand All @@ -42,18 +43,18 @@ sub run {
# Options
my $prefork = Mojo::Server::Prefork->new(app => $self->app);
GetOptionsFromArray \@args,
'B=i' => sub { $prefork->heartbeat_interval($_[1]) },
'b|backlog=i' => sub { $prefork->backlog($_[1]) },
'c|clients=i' => sub { $prefork->max_clients($_[1]) },
'f=i' => sub { $prefork->lock_file($_[1]) },
'G|graceful=i' => sub { $prefork->graceful_timeout($_[1]) },
'g|group=s' => sub { $prefork->group($_[1]) },
'H=i' => sub { $prefork->heartbeat_timeout($_[1]) },
'i|inactivity=i' => sub { $prefork->inactivity_timeout($_[1]) },
'L=i' => sub { $prefork->lock_timeout($_[1]) },
'l|listen=s' => \my @listen,
'P|pid=i' => sub { $prefork->pid_file($_[1]) },
'p|proxy' => sub { $ENV{MOJO_REVERSE_PROXY} = 1 },
'b|backlog=i' => sub { $prefork->backlog($_[1]) },
'c|clients=i' => sub { $prefork->max_clients($_[1]) },
'G|graceful-timeout=i' => sub { $prefork->graceful_timeout($_[1]) },
'g|group=s' => sub { $prefork->group($_[1]) },
'heartbeat-interval=i' => sub { $prefork->heartbeat_interval($_[1]) },
'H|heartbeat-timeout=i' => sub { $prefork->heartbeat_timeout($_[1]) },
'i|inactivity=i' => sub { $prefork->inactivity_timeout($_[1]) },
'lock-file=i' => sub { $prefork->lock_file($_[1]) },
'L|lock-timeout=i' => sub { $prefork->lock_timeout($_[1]) },
'l|listen=s' => \my @listen,
'P|pid-file=i' => sub { $prefork->pid_file($_[1]) },
'p|proxy' => sub { $ENV{MOJO_REVERSE_PROXY} = 1 },
'r|requests=i' => sub { $prefork->max_requests($_[1]) },
'u|user=s' => sub { $prefork->user($_[1]) },
'w|workers=i' => sub { $prefork->workers($_[1]) };
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Commands.pm
Expand Up @@ -185,7 +185,7 @@ Upload files to CPAN.
$ ./myapp.pl daemon
Start application with standalone HTTP server backend.
Start application with standalone HTTP and WebSocket server server.
=head2 eval
Expand Down Expand Up @@ -250,7 +250,7 @@ application into real files.
$ ./myapp.pl prefork
Start application with standalone preforking HTTP server backend.
Start application with standalone preforking HTTP and WebSocket server.
=head2 psgi
Expand Down

0 comments on commit a21896e

Please sign in to comment.