Skip to content

Commit

Permalink
Merge pull request #435 from yuryu/master
Browse files Browse the repository at this point in the history
Plack::Handler::FCGI - Support Server::Starter
  • Loading branch information
miyagawa committed Oct 4, 2014
2 parents 8538f24 + 7136495 commit c02647d
Showing 1 changed file with 18 additions and 1 deletion.
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

0 comments on commit c02647d

Please sign in to comment.