Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better default for Hypnotoad PID file
  • Loading branch information
kraih committed Apr 19, 2014
1 parent 7a4f945 commit fa82aba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -3,7 +3,7 @@ use Mojo::Base -base;

# "Bender: I was God once.
# God: Yes, I saw. You were doing well, until everyone died."
use Cwd 'abs_path';
use Cwd qw(abs_path getcwd);
use File::Basename 'dirname';
use File::Spec::Functions 'catfile';
use Mojo::Server::Prefork;
Expand All @@ -24,8 +24,8 @@ sub configure {
# Prefork settings
$ENV{MOJO_REVERSE_PROXY} = $c->{proxy} if defined $c->{proxy};
$prefork->listen($c->{listen} || ['http://*:8080']);
my $file = catfile dirname($ENV{HYPNOTOAD_APP} // '.'), 'hypnotoad.pid';
$prefork->pid_file($c->{pid_file} || $file);
my $dir = $ENV{HYPNOTOAD_APP} ? dirname $ENV{HYPNOTOAD_APP} : getcwd;
$prefork->pid_file($c->{pid_file} || catfile $dir, 'hypnotoad.pid');
$prefork->max_clients($c->{clients}) if $c->{clients};
$prefork->max_requests($c->{keep_alive_requests})
if $c->{keep_alive_requests};
Expand Down
6 changes: 4 additions & 2 deletions t/mojo/hypnotoad.t
Expand Up @@ -10,7 +10,8 @@ use Test::More;
plan skip_all => 'set TEST_HYPNOTOAD to enable this test (developer only!)'
unless $ENV{TEST_HYPNOTOAD};

use File::Spec::Functions 'catdir';
use Cwd 'getcwd';
use File::Spec::Functions qw(catdir catfile);
use File::Temp 'tempdir';
use FindBin;
use IO::Socket::INET;
Expand Down Expand Up @@ -47,7 +48,8 @@ use Mojo::Util qw(slurp spurt);
is $hypnotoad->upgrade_timeout, 60, 'right default';
$hypnotoad->configure('test');
is_deeply $hypnotoad->prefork->listen, ['http://*:8080'], 'right value';
like $hypnotoad->prefork->pid_file, qr/hypnotoad\.pid$/, 'right value';
is $hypnotoad->prefork->pid_file, catfile(getcwd, 'hypnotoad.pid'),
'right value';
$hypnotoad->configure('myserver');
is $hypnotoad->prefork->accept_interval, 33, 'right value';
is $hypnotoad->prefork->accepts, 13, 'right value';
Expand Down

0 comments on commit fa82aba

Please sign in to comment.