#!perl use strict; use Plack::Runner; my $runner = Plack::Runner->new; $runner->parse_options(@ARGV); $runner->run; __END__ =head1 NAME plackup - Run PSGI application with Plack servers =head1 SYNOPSIS # read your app from app.psgi file plackup # can be passed as an ARGV[0] (or with -a option) plackup hello.psgi # Switch server implementation with --server (or -s) plackup --server HTTP::Server::Simple --port 9090 --host 127.0.0.1 test.psgi # Use UNIX socket to run FCGI daemon plackup -s FCGI --listen /tmp/fcgi.sock myapp.psgi # FCGI external server on port 9090 plackup -s FCGI --port 9090 =head1 DESCRIPTION plackup is a command line utility to run PSGI application from the command line. plackup automatically figures out the environment it is run in, and runs your application in that environment. FastCGI, CGI, AnyEvent and others can all be detected. See L for the authorative list. C assumes you have an C script in your current directory, that would look like: #!/usr/bin/perl use MyApp; my $app = MyApp->new; my $handler = sub { $app->run_psgi(@_) }; The last statement of C should be a code reference that is a PSGI application. =head1 ARGUMENTS =over 4 =item .psgi plackup --host 127.0.0.1 --port 9090 /path/to/app.psgi The first non-option argument is used as a C<.psgi> file path. You can also set this path with C<-a> or C<--app> option. If omitted, the default file path is C in the current directory. =back =head1 OPTIONS =over 4 =item -a, --app C<--app> option allows you to locate a C<.psgi> script with a different name in a different path. This can also be set as a non-option argument. (See above) =item -e Evaluate the given perl code as a PSGI app, much like perl's C<-e> option. plackup -e 'sub { my $env = shift; return [ ... ] }' You can also specify C<-e> option with C<.psgi> file path to wrap the application with middleware configuration from the command line. You can also use L DSL syntax inside C<-e> code. plackup -e 'enable "Auth::Basic", authenticator => ...;' myapp.psgi equals to run the following PSGI application: use Plack::Builder; use Plack::Util; builder { enable "Auth::Basic", authenticator => ...; Plack::Util::load_psgi("myapp.psgi"); }; Note that when you use C<-e> option to enable middleware, plackup doesn't assume the implicit C path. You should always pass C<.psgi> path in the command line arguments. plackup # Runs app.psgi plackup -e 'enable "Foo"' # Doesn't work! plackup -e 'enable "Foo"' app.psgi # Works =item -o, --host The interface a TCP based server daemon binds to. Defauts to undef, which lets most server backends bind the any (*) interface. This opeion doesn't mean anything if the server does not support TCP socket. =item -p, --port The port number a TCP based server daemon listens on. Defaults to 5000. This option doesn't mean anything if the server does not support TCP socket. =item -s, --server Select a specific implementation to run on using the C environment variable or use the C<-s> or C<--server> flag which will be preferred over the environment variable if present. =item -S, --socket UNIX domain socket path to listen on. Defaults to undef. This option doesn't mean anything if the server doesn't support UNIX sockets. =item -l, --listen Addresses to listen on. It could be "HOST:PORT", ":PORT" or "PATH" (without colons). It could be multiple but it depends on the server implementations whether multiple interfaces are supported. =item -D, --daemonize Makes the process go background. It's up to the backend server/handler implementation whether this option is respected or not. =item -I Specify perl library include path, like C's -I option. =item -M Specify modules to load before loading the app code. =item -E, --env Specify the environment option (default is C). You can set this value by setting C environment variable as well, and specifying the value with the command line options writes back to C as well, so applications or frameworks can tell which environment setting the application is running on. # These two are the same plackup -E deployment env PLACK_ENV=deployment plackup The value can be anything but commonly used ones are C, C and C. If it's set to C, following middleware components are enabled by default: I, I and I. =item -r, --reload Make plackup to watch updates from your development directory and restarts the server whenever a file is updated. This option by default watches the C directory and the base directory where I<.psgi> file is located. Use C<-R> if you want to watch other directories. =item -R, --Reload C<-R> option allows you to specify the path to watch file updates separated by comma (C<,>). plackup -R /path/to/project/lib,/path/to/project/templates =item -L, --loader Specify the server loading subclass that implements how to run the server. Available options are I (default), I (automatically set when C<-r> or C<-R> is used), I and I. See L and L when to use those loader types. =item --access-log Specify the pathname of a file where the access log should be written. By default, in the development environment access logs will go to STDERR. =back Other options that starts with C<--> are passed through to the backend server. See each Plack::Handler backend documentations to see which options are available. =head1 SEE ALSO L L =cut