/
starman
executable file
·149 lines (98 loc) · 3.91 KB
/
starman
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/perl
use strict;
use lib "lib";
use Plack::Runner;
sub version {
require Starman;
print "Starman $Starman::VERSION\n";
}
my $preload_app;
require Getopt::Long;
Getopt::Long::Configure("no_ignore_case", "no_auto_abbrev", "pass_through");
Getopt::Long::GetOptions(
"preload-app" => \$preload_app,
);
my @args = (server => 'Starman', env => 'deployment', version_cb => \&version);
if (!$preload_app) {
push @args, 'loader' => 'Delayed';
}
my @argv = @ARGV;
my $runner = Plack::Runner->new(@args);
$runner->parse_options(@argv);
$runner->set_options(argv => \@argv);
$runner->run;
__END__
=head1 NAME
starman - Starman launcher
=head1 SYNOPSIS
starman --listen :5001 --listen /tmp/starman.sock
starman --workers 32 --port 8080
=over 4
=item -l, --listen
--listen HOST:PORT --listen :PORT --listen UNIX_SOCKET
Specifies the TCP address, ports and UNIX domain sockets to bind to
wait for requests. You can repeat as many times as you want and mix
TCP and UNIX domain sockets.
Defaults to any IP address and port 5000.
=item --host
--host 127.0.0.1
Specifies the address to bind.
This option is for a compatiblity with L<plackup> and you're
recommended to use C<--listen> instead.
=item --port
--port 8080
Specifies the port to bind.
This option is for a compatiblity with L<plackup> and you're
recommended to use C<--listen> instead.
=item -S, --socket
-S /tmp/starman.sock
Specifies the path to UNIX domain socket to bind.
This option is for a compatiblity with L<plackup> and you're
recommended to use C<--listen> instead.
=item --workers
Specifies the number of worker pool. Defaults to 5.
Starman by default sets up other spare server configuration based on this
workers value, making sure there are B<always only> C<N> worker
processes running. So even if there're no idle workers, Starman won't
spawn off spare processes since that's mostly what you want to do by
fine tuning the memory usage etc. in the production environment.
=item --backlog
Specifies the number of backlog (listen queue size) of listener sockets. Defaults to 1024.
On production systems, setting a very low value can allow failover on
frontend proxy (like nginx) to happen more quickly, if you have
multiple Starman clusters.
If you're doing simple benchmarks and getting connection errors,
increasing this parameter can help avoid them. You should also
consider increasing C<net.core.somaxconn>. Note that this is not
recommended for real production system if you have another cluster to
failover (see above).
=item --max-requests
Number of the requests to process per one worker process. Defaults to 1000.
=item --preload-app
This option lets Starman preload the specified PSGI application in the
master parent process before preforking children. This allows memory
savings with copy-on-write memory management. When not set (default),
forked children loads the application in the initialization hook.
Enabling this option can cause bad things happen when resources like
sockets or database connections are opened at load time by the master
process and shared by multiple children.
Since Starman 0.2000, this option defaults to false, and you should
explicitly set this option to preload the application in the master
process.
Alternatively, you can use -M command line option (plackup's common
option) to preload the I<modules> rather than the <application>
itself.
starman -MCatalyst -MDBIx::Class myapp.psgi
will load the modules in the master process for memory savings with
CoW, but the actual loading of C<myapp.psgi> is done per children,
allowing resource managements such as database connection safer.
=item --disable-keepalive
Disable Keep-alive persistent connections. It is an useful workaround
if you run Starman behind a broken frontend proxy that tries to pool
connections more than a number of backend workers (i.e. Apache
mpm_prefork + mod_proxy).
=back
See `plackup -h` for more options.
=head1 SEE ALSO
L<Starman>
=cut