plackup - Run PSGI application with Plack servers
# 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
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 Plack::Loader for the authorative list.
plackup assumes you have an app.psgi script in your current directory, that would look like:
plackup
app.psgi
#!/usr/bin/perl use MyApp; my $app = MyApp->new; my $handler = sub { $app->run_psgi(@_) };
The last statement of app.psgi should be a code reference that is a PSGI application.
plackup --host 127.0.0.1 --port 9090 /path/to/app.psgi
The first non-option argument is used as a .psgi file path. You can also set this path with -a or --app option. If omitted, the default file path is app.psgi in the current directory.
.psgi
-a
--app
--app option allows you to locate a .psgi script with a different name in a different path. This can also be set as a non-option argument. (See above)
Evaluate the given perl code as a PSGI app, much like perl's -e option.
-e
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.
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.
Select a specific implementation to run on using the PLACK_SERVER environment variable or use the -s or --server flag which will be preferred over the environment variable if present.
PLACK_SERVER
-s
--server
UNIX domain socket path to listen on. Defaults to undef. This option doesn't mean anything if the server doesn't support UNIX sockets.
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.
Makes the process go background. It's up to the backend server/handler implementation whether this option is respected or not.
Specify perl library include path, like perl's -I option.
perl
Specify modules to load before loading the app code.
Specify the environment option (default is development). You can set this value by setting PLACK_ENV environment variable as well, and specifying the value with the command line options writes back to PLACK_ENV as well, so applications or frameworks can tell which environment setting the application is running on.
development
PLACK_ENV
# These two are the same plackup -E deployment env PLACK_ENV=deployment plackup
The value can be anything but commonly used ones are development, deployment and test.
deployment
test
If it's set to development, following middleware components are enabled by default: AccessLog, StackTrace and Lint.
Make plackup to watch updates from your development directory and restarts the server whenever a file is updated. This option by default watches the lib directory and the base directory where .psgi file is located. Use -R if you want to watch other directories.
lib
-R
-R option allows you to specify the path to watch file updates separated by comma (,).
,
plackup -R /path/to/project/lib,/path/to/project/templates
Specify the server loading subclass that implements how to run the server. Available options are Plack::Loader (default), Restarter (automatically set when -r or -R is used), Delayed and Shotgun.
-r
See Plack::Loader::Delayed and Plack::Loader::Shotgun when to use those loader types.
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.
Other options that starts with -- are passed through to the backend server. See each Plack::Handler backend documentations to see which options are available.
--
Plack::Runner Plack::Loader
To install Plack, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack
CPAN shell
perl -MCPAN -e shell install Plack
For more information on module installation, please visit the detailed CPAN module installation guide.