Permalink
Browse files

add option to kill 'HUP' to restart instead of exit.

  • Loading branch information...
1 parent 24999dd commit 7ba85b9598a51cb818a63d17b309fb25d5b091b3 @singingfish committed Jun 29, 2011
Showing with 15 additions and 4 deletions.
  1. +3 −1 Changes
  2. +12 −3 lib/Catalyst/Plugin/AutoRestart.pm
View
@@ -1,4 +1,6 @@
-
+0.94 2011-06-29
+ - Add option to kill through HUP signal instead of exit.
+
0.93 2010-01-29
- Changing Class::C3 to MRO::Compat
@@ -11,7 +11,7 @@ use Proc::ProcessTable;
__PACKAGE__->mk_classaccessor(qw/_autorestart_state/);
-our $VERSION = '0.93';
+our $VERSION = '0.94';
=head1 NAME
@@ -29,13 +29,15 @@ use Catalyst qw/AutoRestart/;
min_handled_requests => '150',
size_field => 'size', # or any other field supported by
# Proc::ProcessTable::Process
+ restart => 'exit', # alternative is kill for a more graceful restart
}
<Plugin::AutoRestart>
active 1
check_each 20
max_bits 576716800
min_handled_requests 150
+ restart exit
</Plugin::AutoRestart>
=head1 DESCRIPTION
@@ -99,6 +101,7 @@ sub setup {
max_bits => 524288000,
min_handled_requests => 500,
size_field => 'size',
+ restart => 'exit',
%$config
} );
@@ -129,10 +132,16 @@ sub handle_request {
$c->log->warn("Found size is $size");
if(defined $size && $size > $state->{max_bits} ) {
- # this actually wont output to log since it exits
+ # this wont output to log since it exits unless
+ # $config->{restart} is set to 'kill'
$c->log->warn("$size is bigger than: ".$state->{max_bits}. " exiting now...");
$c->log->_flush if $c->log->can("_flush");
- exit(0);
+ if ($state->{restart} eq 'exit') {
+ exit(0);
+ }
+ elsif ($state->{restart} eq 'kill') {
+ kill 'HUP', $$;
+ }
}
$c->log->_flush if $c->log->can("_flush");
}

0 comments on commit 7ba85b9

Please sign in to comment.