Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plack::Handler::FCGI - Support Server::Starter #435

Merged
merged 2 commits into from
Oct 4, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/Plack/Handler/FCGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ sub new {
sub run {
my ($self, $app) = @_;

my $running_on_server_starter = exists $ENV{SERVER_STARTER_PORT};
my $sock = 0;
if (-S STDIN) {
# running from web server. Do nothing
# Note it should come before listen check because of plackup's default
} elsif ($running_on_server_starter) {
# Runing under Server::Starter
require Server::Starter;
my %socks = %{Server::Starter::server_ports()};
if (scalar(keys(%socks)) > 1) {
die "More than one socket are specified by Server::Starter";
}
$sock = (values %socks)[0];
} elsif ($self->{listen}) {
my $old_umask = umask;
unless ($self->{leave_umask}) {
Expand All @@ -60,7 +69,7 @@ sub run {

my $proc_manager;

if ($self->{listen}) {
if ($self->{listen} or $running_on_server_starter) {
$self->daemon_fork if $self->{daemonize};

if ($self->{manager}) {
Expand Down Expand Up @@ -409,6 +418,14 @@ mod_fcgid:

FcgiPassHeader Authorization

=head2 Server::Starter

This plack handler supports L<Server::Starter> as a superdaemon.
Simply launch plackup from start_server with a path option.
The listen option is ignored when launched from Server::Starter.

start_server --path=/tmp/socket -- plackup -s FCGI app.psgi

=head1 SEE ALSO

L<Plack>
Expand Down