Skip to content

Commit

Permalink
renamed pid_from_file to check_pid
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 17, 2013
1 parent f0a4e01 commit c0e6cd1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -94,7 +94,7 @@ sub _hot_deploy {
my $self = shift;

# Make sure server is running
return unless my $pid = $self->{prefork}->pid_from_file;
return unless my $pid = $self->{prefork}->check_pid;

# Start hot deployment
kill 'USR2', $pid;
Expand Down Expand Up @@ -139,7 +139,7 @@ sub _reap {

sub _stop {
_exit('Hypnotoad server not running.')
unless my $pid = shift->{prefork}->pid_from_file;
unless my $pid = shift->{prefork}->check_pid;
kill 'QUIT', $pid;
_exit("Stopping Hypnotoad server $pid gracefully.");
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Server/Morbo.pm
Expand Up @@ -26,8 +26,8 @@ sub run {
my ($self, $app) = @_;

# Prepare environment
$SIG{CHLD} = sub { $self->_reap };
$SIG{INT} = $SIG{TERM} = $SIG{QUIT} = sub {
local $SIG{CHLD} = sub { $self->_reap };
local $SIG{INT} = local $SIG{TERM} = local $SIG{QUIT} = sub {
$self->{finished} = 1;
kill 'TERM', $self->{running} if $self->{running};
};
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojo/Server/Prefork.pm
Expand Up @@ -30,7 +30,7 @@ sub DESTROY {
if (my $file = $self->pid_file) { unlink $file if -w $file }
}

sub pid_from_file {
sub check_pid {

# Get PID
my $file = shift->pid_file;
Expand Down Expand Up @@ -479,14 +479,14 @@ worker processes per CPU core.
L<Mojo::Server::Prefork> inherits all methods from L<Mojo::Server::Daemon> and
implements the following new ones.
=head2 pid_from_file
=head2 check_pid
my $pid = $prefork->pid_from_file;
my $pid = $prefork->check_pid;
Get process id for running server from C<pid_file> or delete it if it has been
abandoned.
Get process id for running server from C<pid_file> or delete it if server is
not running.
say 'Server is not running' unless $prefork->pid_from_file;
say 'Server is not running' unless $prefork->check_pid;
=head2 run
Expand Down
6 changes: 3 additions & 3 deletions t/mojo/prefork.t
Expand Up @@ -20,10 +20,10 @@ use Mojo::Util 'spurt';
# Clean up PID file
my $prefork = Mojo::Server::Prefork->new;
my $file = $prefork->pid_file;
ok !$prefork->pid_from_file, 'no process id';
ok !$prefork->check_pid, 'no process id';
spurt "\n", $file;
ok -e $file, 'file exists';
ok !$prefork->pid_from_file, 'no process id';
ok !$prefork->check_pid, 'no process id';
ok !-e $file, 'file has been cleaned up';

# Multiple workers and graceful shutdown
Expand Down Expand Up @@ -63,7 +63,7 @@ is $tx->res->code, 200, 'right status';
is $tx->res->body, 'just works!', 'right content';

# Process id and lock files
is $prefork->pid_from_file, $$, 'right process id';
is $prefork->check_pid, $$, 'right process id';
my $pid = $prefork->pid_file;
ok -e $pid, 'process id file has been created';
my $lock = $prefork->lock_file;
Expand Down

0 comments on commit c0e6cd1

Please sign in to comment.