1PLACKUP(1)            User Contributed Perl Documentation           PLACKUP(1)
2
3
4

NAME

6       plackup - Run PSGI application with Plack servers
7

SYNOPSIS

9         # read your app from app.psgi file
10         plackup
11
12         # choose .psgi file from ARGV[0] (or with -a option)
13         plackup hello.psgi
14
15         # switch server implementation with --server (or -s)
16         plackup --server HTTP::Server::Simple --port 9090 --host 127.0.0.1 test.psgi
17
18         # use UNIX socket to run FCGI daemon
19         plackup -s FCGI --listen /tmp/fcgi.sock myapp.psgi
20
21         # launch FCGI external server on port 9090
22         plackup -s FCGI --port 9090
23

DESCRIPTION

25       plackup is a command line utility to run PSGI applications from the
26       command line.
27
28       plackup automatically figures out the environment it is run in, and
29       runs your application in that environment. FastCGI, CGI, AnyEvent and
30       others can all be detected. See Plack::Loader for the authorative list.
31
32       "plackup" assumes you have an "app.psgi" script in your current
33       directory.  The last statement of "app.psgi" should be a code reference
34       that is a PSGI application:
35
36         #!/usr/bin/perl
37         use MyApp;
38         my $application = MyApp->new;
39         my $app = sub { $application->run_psgi(@_) };
40

ARGUMENTS

42       .psgi
43             plackup --host 127.0.0.1 --port 9090 /path/to/app.psgi
44
45           The first non-option argument is used as a ".psgi" file path. You
46           can also set this path with "-a" or "--app". If omitted, the
47           default file path is "app.psgi" in the current directory.
48

OPTIONS

50       -a, --app
51           Specifies the full path to a ".psgi" script. You may alternately
52           provide this path as the first argument to "plackup".
53
54       -e  Evaluates the given perl code as a PSGI app, much like perl's "-e"
55           option:
56
57             plackup -e 'sub { my $env = shift; return [ ... ] }'
58
59           It is also handy when you want to run a custom application like
60           Plack::App::*.
61
62             plackup -MPlack::App::File -e 'Plack::App::File->new(...)->to_app'
63
64           You can also specify "-e" option with ".psgi" file path to wrap the
65           application with middleware configuration from the command line.
66           You can also use Plack::Builder DSL syntax inside "-e" code. For
67           example:
68
69             plackup -e 'enable "Auth::Basic", authenticator => ...;' myapp.psgi
70
71           is equivalent to the PSGI application:
72
73             use Plack::Builder;
74             use Plack::Util;
75
76             builder {
77                 enable "Auth::Basic", authenticator => ...;
78                 Plack::Util::load_psgi("myapp.psgi");
79             };
80
81           Note that when you use "-e" option to enable middleware, plackup
82           doesn't assume the implicit "app.psgi" path. You must either pass
83           the path to your ".psgi" file in the command line arguments, or
84           load the application inside "-e" after the "enable".
85
86             plackup                                # Runs app.psgi
87             plackup -e 'enable "Foo"'              # Doesn't work!
88             plackup -e 'enable "Foo"' app.psgi     # Works
89             plackup -e 'enable "Foo"; sub { ... }' # Works
90
91       -o, --host
92           Binds to a TCP interface. Defauts to undef, which lets most server
93           backends bind the any (*) interface. This option is only valid for
94           servers which support TCP sockets.
95
96       -p, --port
97           Binds to a TCP port. Defaults to 5000. This option is only valid
98           for servers which support TCP sockets.
99
100       -s, --server, the "PLACK_SERVER" environment variable
101           Selects a specific server implementation to run on. When provided,
102           the "-s" or "--server" flag will be preferred over the environment
103           variable.
104
105           If no option is given, plackup will try to detect the best server
106           implementation based on the environment variables as well as
107           modules loaded by your application in %INC. See Plack::Loader for
108           details.
109
110       -S, --socket
111           Listens on a UNIX domain socket path. Defaults to undef. This
112           option is only valid for servers which support UNIX sockets.
113
114       -l, --listen
115           Listens on one or more addresses, whether "HOST:PORT", ":PORT", or
116           "PATH" (without colons). You may use this option multiple times to
117           listen on multiple addresses, but the server will decide whether it
118           supports multiple interfaces.
119
120       -D, --daemonize
121           Makes the process run in the background. It's up to the backend
122           server/handler implementation whether this option is respected or
123           not.
124
125       -I  Specifies Perl library include paths, like "perl"'s -I option. You
126           may add multiple paths by using this option multiple times.
127
128       -M  Loads the named modules before loading the app's code. You may load
129           multiple modules by using this option multiple times.
130
131       -E, --env, the "PLACK_ENV" environment variable.
132           Specifies the environment option. Setting this value with "-E" or
133           "--env" also writes to the "PLACK_ENV" environment variable. This
134           allows applications or frameworks to tell which environment setting
135           the application is running on.
136
137             # These two are the same
138             plackup -E deployment
139             env PLACK_ENV=deployment plackup
140
141           Common values are "development", "deployment", and "test". The
142           default value is "development", which causes "plackup" to load the
143           middleware components: AccessLog, StackTrace and Lint.
144
145       -r, --reload
146           Makes plackup restart the server whenever a file in your
147           development directory changes. This option by default watches the
148           "lib" directory and the base directory where .psgi file is located.
149           Use "-R" to watch other directories.
150
151           Reloading will delay the compilation of your application. Automatic
152           server detection (see "-s" above) may not behave as you expect, if
153           plackup needs to scan your application for the modules it uses.
154           Avoid problems by specifying "-s" explicitly when using "-r" or
155           "-R".
156
157       -R, --Reload
158           Makes plackup restart the server whenever a file in any of the
159           given directories changes. "-R" and "--Reload" take a comma-
160           separated list of paths:
161
162             plackup -R /path/to/project/lib,/path/to/project/templates
163
164       -L, --loader
165           Specifies the server loading subclass that implements how to run
166           the server.  Available options are Plack::Loader (default),
167           Restarter (automatically set when "-r" or "-R" is used), Delayed
168           and Shotgun.
169
170           See Plack::Loader::Delayed and Plack::Loader::Shotgun for more
171           details.
172
173       --access-log
174           Specifies the pathname of a file where the access log should be
175           written.  By default, in the development environment access logs
176           will go to STDERR.
177
178       Other options that starts with "--" are passed through to the backend
179       server.  See each Plack::Handler backend's documentation for more
180       details on their available options.
181

SEE ALSO

183       Plack::Runner Plack::Loader
184
185
186
187perl v5.12.3                      2011-07-14                        PLACKUP(1)
Impressum