← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:33:30 2016

Filename/usr/bin/starman
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11124µs1.49msCGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::::BEGIN@39CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@39
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
011.49msProfile data that couldn't be associated with a specific line:
1#!/usr/bin/perl
2use strict;
3use Plack::Runner;
4
5sub version {
6 require Starman;
7 print "Starman $Starman::VERSION\n";
8}
9
10my $preload_app;
11
12require Getopt::Long;
13Getopt::Long::Configure("no_ignore_case", "no_auto_abbrev", "pass_through");
14Getopt::Long::GetOptions(
15 "preload-app" => \$preload_app,
16);
17
18my @args = (server => 'Starman', env => 'deployment', version_cb => \&version);
19if (!$preload_app) {
20 push @args, 'loader' => 'Delayed';
21}
22
23my @argv = @ARGV;
24
25my $runner = Plack::Runner->new(@args);
26$runner->parse_options(@argv);
27
28if ($runner->{loader} eq 'Restarter') {
29 warn <<WARN;
30!!
31!! Using restarter with -r or -R options is known to cause issues with process supervisor
32!! such as start_server, and it is STRONGLY discouraged to use with Starman. You have been warned.
33!!
34WARN
35}
36
37$runner->set_options(argv => \@argv);
38$runner->run;
39
# spent 1.49ms (24µs+1.47) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@39 which was called: # once (24µs+1.47ms) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:binmode at line 0
40__END__
41
42=head1 NAME
43
44starman - Starman launcher
45
46=head1 SYNOPSIS
47
48 starman --listen :5001 --listen /tmp/starman.sock
49 starman --workers 32 --port 8080
50
51=head1 OPTIONS
52
53=over 4
54
55=item -l, --listen
56
57 --listen HOST:PORT --listen :PORT --listen UNIX_SOCKET
58 --listen HOST:PORT:ssl
59
60Specifies the TCP address, ports and UNIX domain sockets to bind to
61wait for requests. You can repeat as many times as you want and mix
62TCP and UNIX domain sockets.
63
64For TCP sockets you can append C<:ssl> after the port to specify that
65connections on that port should use SSL. Note that the SSL support is
66experimental and hasn't been widely tested.
67
68Defaults to any IP address and port 5000.
69
70=item --host
71
72 --host 127.0.0.1
73
74Specifies the address to bind.
75
76This option is for a compatibility with L<plackup> and you're
77recommended to use C<--listen> instead.
78
79=item --port
80
81 --port 8080
82
83Specifies the port to bind.
84
85This option is for a compatibility with L<plackup> and you're
86recommended to use C<--listen> instead.
87
88=item -S, --socket
89
90 -S /tmp/starman.sock
91
92Specifies the path to UNIX domain socket to bind.
93
94This option is for a compatibility with L<plackup> and you're
95recommended to use C<--listen> instead.
96
97=item --workers
98
99Specifies the number of worker pool. Defaults to 5.
100
101Starman by default sets up other spare server configuration based on this
102workers value, making sure there are B<always only> C<N> worker
103processes running. So even if there're no idle workers, Starman won't
104spawn off spare processes since that's mostly what you want to do by
105fine tuning the memory usage etc. in the production environment.
106
107=item --backlog
108
109Specifies the number of backlog (listen queue size) of listener sockets. Defaults to 1024.
110
111On production systems, setting a very low value can allow failover on
112frontend proxy (like nginx) to happen more quickly, if you have
113multiple Starman clusters.
114
115If you're doing simple benchmarks and getting connection errors,
116increasing this parameter can help avoid them. You should also
117consider increasing C<net.core.somaxconn>. Note that this is not
118recommended for real production system if you have another cluster to
119failover (see above).
120
121=item --max-requests
122
123Number of the requests to process per one worker process. Defaults to 1000.
124
125=item --preload-app
126
127This option lets Starman preload the specified PSGI application in the
128master parent process before preforking children. This allows memory
129savings with copy-on-write memory management. When not set (default),
130forked children loads the application in the initialization hook.
131
132Enabling this option can cause bad things happen when resources like
133sockets or database connections are opened at load time by the master
134process and shared by multiple children.
135
136Since Starman 0.2000, this option defaults to false, and you should
137explicitly set this option to preload the application in the master
138process.
139
140Alternatively, you can use -M command line option (plackup's common
141option) to preload the I<modules> rather than the <application>
142itself.
143
144 starman -MCatalyst -MDBIx::Class myapp.psgi
145
146will load the modules in the master process for memory savings with
147CoW, but the actual loading of C<myapp.psgi> is done per children,
148allowing resource managements such as database connection safer.
149
150If you enable this option, sending C<HUP> signal to the master process
151I<will not> pick up any code changes you make. See L</SIGNALS> for
152details.
153
154=item --disable-keepalive
155
156Disable Keep-alive persistent connections. It is an useful workaround
157if you run Starman behind a broken frontend proxy that tries to pool
158connections more than a number of backend workers (i.e. Apache
159mpm_prefork + mod_proxy).
160
161=item --keepalive-timeout
162
163The number of seconds Starman will wait for a subsequent request
164before closing the connection if Keep-alive persistent connections
165are enabled. Setting this to a high value may cause performance
166problems in heavily loaded servers. The higher the timeout, the
167more backend workers will be kept occupied waiting on connections
168with idle clients.
169
170Defaults to 1.
171
172=item --read-timeout
173
174The number of seconds Starman will wait for a request on a new connection
175before closing it. Setting this to a high value may cause performance
176problems in heavily loaded servers. The higher the timeout, the
177more backend workers will be kept occupied waiting on connections
178with idle clients. You may need this if your proxy / load balancer likes to
179keep a pool of open connections while waiting for clients (eg. Amazon ELB).
180
181Defaults to 5.
182
183=item --user
184
185To listen on a low-numbered (E<lt>1024) port, it will be necessary to
186start the server as root. Use the C<--user> option to specify a userid
187or username that the server process should switch to after binding to
188the port.
189
190Defaults to the current userid.
191
192=item --group
193
194Specify the group id or group name that the server should switch to after
195binding to the port. This option is usually used with C<--user>.
196
197Defaults to the current group id.
198
199=item --pid
200
201Specify the pid file path. Use it with C<-D|--daemonize> option,
202described in C<plackup -h>.
203
204=item --error-log
205
206Specify the pathname of a file where the error log should be written.
207This enables you to still have access to the errors when using C<--daemonize>.
208
209=item --ssl-cert
210
211Specify the path to SSL certificate file.
212
213=item --ssl-key
214
215Specify the path to SSL key file.
216
217=item --enable-ssl
218
219Enable SSL on I<all> TCP sockets. This is an experimental feature.
220
221=item --disable-proctitle
222
223Disable the behavior to set proctitle to "starman (master)" and
224"starman (worker)" respectively on master and workers.
225
226=back
227
228Starman passes through other options given to L<Plack::Runner>, the
229common backend that L<plackup> uses, so the most options explained in
230C<plackup -h> such as C<--access-log> or C<--daemonize> works fine in
231starman too.
232
233Setting the environment variable C<STARMAN_DEBUG> to 1 makes the
234Starman server running in the debug mode.
235
236=cut
237
238=head1 SIGNALS
239
240=over 4
241
242=item HUP
243
244Sending C<HUP> signal to the master process will restart all the workers
245gracefully (meaning the currently running requests will shut down once
246the request is complete), and by default, the workers will pick up the
247code changes you make by reloading the application.
248
249If you enable C<--preload-app> option, however, the code will be only
250loaded in the startup process and will not pick up the code changes
251you made. If you want to preload the app I<and> do graceful restarts
252by reloading the code changes, you're recommended to use
253L<Server::Starter>, configured to send C<QUIT> signal when superdaemon
254received C<HUP>, i.e:
255
256 start_server --interval 5 --port 8080 --signal-on-hup=QUIT -- \
257 starman --preload-app myapp.psgi
258
259You will then send the HUP signal to C<start_server> process to
260gracefully reload the starman cluster (master and workers).
261
262With Server::Starter 0.12 or later, you should also be able to set
263C<--signal-on-term> to QUIT so that you can safely shutdown Starman
264first and then stop the C<start_server> daemon process as well.
265
266=item TTIN, TTOU
267
268Sending C<TTIN> signal to the master process will dynamically increase
269the number of workers, and C<TTOU> signal will decrease it.
270
271=item INT, TERM
272
273Sending C<INT> or C<TERM> signal to the master process will kill all
274the workers immediately and shut down the server.
275
276=item QUIT
277
278Sending C<QUIT> signal to the master process will gracefully shutdown
279the workers (meaning the currently running requests will shut down
280once the request is complete).
281
282=back
283
284=head1 RELOADING THE APPLICATION
285
286You're recommended to use signals (see above) to reload the
287application, and are strongly discouraged to use C<-r> or C<-R>
288(reloading flag) from plackup. These options will make a separate
289directory watcher process, and makes your life difficult if you want to
290combine with other process daemon tools such as L<Server::Starter>.
291
292=head1 DIFFERENCES WITH PLACKUP
293
294C<starman> executable is basically the equivalent of using C<plackup>
295with C<Starman> server handler i.e. C<plackup -s Starman>, except that
296C<starman> delay loads the application with the Delayed loader by
297default, which can be disabled with C<--preload-app>.
298
299C<starman> command also automatically sets the environment (C<-E>) to
300the value of I<deployment>.
301
302You're recommended to use C<starman> unless there's a reason to stick to
303C<plackup> for compatibility.
304
305=head1 SEE ALSO
306
307L<Starman>
308
309=cut