Browse files

Document preload-app

  • Loading branch information...
miyagawa committed Apr 14, 2010
1 parent 133f90a commit 12ea3717c85ee5601d230f6c1da896c8d75b20ef
Showing with 30 additions and 3 deletions.
  1. +25 −0 bin/starman
  2. +4 −3 lib/
  3. +1 −0 lib/Starman/
@@ -105,6 +105,31 @@ failover (see above).
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
+Alternatively, you can use -M command line option (plackup's common
+option) to preload the I<modules> rather than the <application>
+ 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
@@ -57,9 +57,10 @@ Able to listen on multiple intefaces including UNIX sockets.
=item Small memory footprint
-Preloading the applications enables copy-on-write friendly memory
-management. Also, the minimum memory usage Starman requires for the
-master process is 7MB and children (workers) is less than 3.0MB.
+Preloading the applications with C<--preload-app> command line option
+enables copy-on-write friendly memory management. Also, the minimum
+memory usage Starman requires for the master process is 7MB and
+children (workers) is less than 3.0MB.
=item PSGI compatible
@@ -101,6 +101,7 @@ sub pre_loop_hook {
sub child_init_hook {
my $self = shift;
if ($self->{options}->{psgi_app_builder}) {
+ DEBUG && warn "[$$] Initializing the PSGI app\n";
$self->{app} = $self->{options}->{psgi_app_builder}->();
$0 = "starman worker " . join(" ", @{$self->{options}{argv} || []});

0 comments on commit 12ea371

Please sign in to comment.