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

NAME

6       plackup - Run PSGI application with Plack handlers
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 authoritative
31       list.
32
33       "plackup" assumes you have an "app.psgi" script in your current
34       directory.  The last statement of "app.psgi" should be a code reference
35       that is a PSGI application:
36
37         #!/usr/bin/perl
38         use MyApp;
39         my $application = MyApp->new;
40         my $app = sub { $application->run_psgi(@_) };
41

ARGUMENTS

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

OPTIONS

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

SEE ALSO

207       Plack::Runner Plack::Loader
208
209
210
211perl v5.32.1                      2021-01-27                        PLACKUP(1)
Impressum