1PLACKUP(1) User Contributed Perl Documentation PLACKUP(1)
2
3
4
6 plackup - Run PSGI application with Plack handlers
7
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
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
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
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 Note: default port 5000 may conflict with AirPlay server on MacOS
102 12 (Monterey) or later.
103
104 -s, --server, the "PLACK_SERVER" environment variable
105 Selects a specific server implementation to run on. When provided,
106 the "-s" or "--server" flag will be preferred over the environment
107 variable.
108
109 If no option is given, plackup will try to detect the best server
110 implementation based on the environment variables as well as
111 modules loaded by your application in %INC. See Plack::Loader for
112 details.
113
114 -S, --socket
115 Listens on a UNIX domain socket path. Defaults to undef. This
116 option is only valid for servers which support UNIX sockets.
117
118 -l, --listen
119 Listens on one or more addresses, whether "HOST:PORT", ":PORT", or
120 "PATH" (without colons). You may use this option multiple times to
121 listen on multiple addresses, but the server will decide whether it
122 supports multiple interfaces.
123
124 -D, --daemonize
125 Makes the process run in the background. It's up to the backend
126 server/handler implementation whether this option is respected or
127 not.
128
129 -I Specifies Perl library include paths, like "perl"'s -I option. You
130 may add multiple paths by using this option multiple times.
131
132 -M Loads the named modules before loading the app's code. You may load
133 multiple modules by using this option multiple times.
134
135 In combination with "-r" or "-R" may not have the desired restart
136 effect when the loaded module is changed in the development
137 directory. To avoid this problem you need to load the module with
138 the app code using "-e".
139
140 -E, --env, the "PLACK_ENV" environment variable.
141 Specifies the environment option. Setting this value with "-E" or
142 "--env" also writes to the "PLACK_ENV" environment variable. This
143 allows applications or frameworks to tell which environment setting
144 the application is running on.
145
146 # These two are the same
147 plackup -E deployment
148 env PLACK_ENV=deployment plackup
149
150 Common values are "development", "deployment", and "test". The
151 default value is "development", which causes "plackup" to load the
152 middleware components: AccessLog, StackTrace, and Lint unless
153 "--no-default-middleware" is set.
154
155 --no-default-middleware
156 This prevents loading the default middleware stack even when Plack
157 environment (i.e. "-E" or "PLACK_ENV") is set to "development".
158
159 -r, --reload
160 Makes plackup restart the server whenever a file in your
161 development directory changes. This option by default watches the
162 "lib" directory and the base directory where .psgi file is located.
163 Use "-R" to watch other directories.
164
165 Reloading will delay the compilation of your application. Automatic
166 server detection (see "-s" above) may not behave as you expect, if
167 plackup needs to scan your application for the modules it uses.
168 Avoid problems by specifying "-s" explicitly when using "-r" or
169 "-R".
170
171 To avoid problems with changes to preloaded modules see
172 documentation for "-M".
173
174 -R, --Reload
175 Makes plackup restart the server whenever a file in any of the
176 given directories changes. "-R" and "--Reload" take a comma-
177 separated list of paths:
178
179 plackup -R /path/to/project/lib,/path/to/project/templates
180
181 To avoid problems with changes to preloaded modules see
182 documentation for "-M".
183
184 -L, --loader
185 Specifies the server loading subclass that implements how to run
186 the server. Available options are Plack::Loader (default),
187 Restarter (automatically set when "-r" or "-R" is used), Delayed,
188 and Shotgun.
189
190 See Plack::Loader::Delayed and Plack::Loader::Shotgun for more
191 details.
192
193 --access-log
194 Specifies the pathname of a file where the access log should be
195 written. By default, in the development environment access logs
196 will go to STDERR.
197
198 --path
199 Specify the root path of your app ("SCRIPT_NAME" in PSGI env) to
200 run. The following two commands are roughly the same.
201
202 plackup --path /foo app.psgi
203 plackup -e 'mount "/foo" => Plack::Util::load_psgi("app.psgi")'
204
205 Other options that starts with "--" are passed through to the backend
206 server. See each Plack::Handler backend's documentation for more
207 details on their available options.
208
210 Plack::Runner Plack::Loader
211
212
213
214perl v5.38.0 2023-07-21 PLACKUP(1)