Skip to content

Instantly share code, notes, and snippets.

@jshirley
Created June 2, 2009 21:49
Show Gist options
  • Save jshirley/122621 to your computer and use it in GitHub Desktop.
Save jshirley/122621 to your computer and use it in GitHub Desktop.
Index: lib/Catalyst/Engine/HTTP/Prefork.pm
===================================================================
--- lib/Catalyst/Engine/HTTP/Prefork.pm (revision 10421)
+++ lib/Catalyst/Engine/HTTP/Prefork.pm (working copy)
@@ -33,7 +33,15 @@
# Restore ARGV since Getopt has eaten it and Net::Server needs it
# for proper restart support
@ARGV = @{ $options->{argv} };
-
+
+ my %extra = ();
+ if ( $options->{pidfile} or $options->{pid_file} ) {
+ $extra{pid_file} = $options->{pidfile} || $options->{pid_file};
+ }
+ if ( $options->{background} ) {
+ $extra{setsid} = $extra{background} = 1;
+ }
+
$self->SUPER::run(
port => $port || 3000,
host => $host || '*',
@@ -45,6 +53,8 @@
max_servers => $options->{max_servers} || 50,
max_requests => $options->{max_requests} || 1000,
leave_children_open_on_hup => $options->{restart_graceful} || 0,
+
+ %extra
);
}
@@ -385,6 +395,16 @@
will not attempt to close child processes if the parent receives a SIGHUP. Each
child will exit as soon as possible after processing the current request if any.
+=head2 pidfile
+
+This passes through to Net::Server's pid_file option. If set, the pidfile is
+written to the path. Default is none. This file is not removed on server exit
+
+=head2 background
+
+This option passes through to Net::Server and also sets the 'setsid' option to
+true.
+
=head1 AUTHOR
Andy Grundman, <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment