From: Jonathan Rockway Date: Tue, 12 May 2009 00:36:08 +0000 (-0500) Subject: setup signals from the command line X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a496e4e50c505bab75dbc1e8e47324a7901bf9dc;p=gitmo%2FMooseX-Runnable.git setup signals from the command line --- diff --git a/lib/MooseX/Runnable/Invocation/Plugin/Restart.pm b/lib/MooseX/Runnable/Invocation/Plugin/Restart.pm index cc49382..424cefe 100644 --- a/lib/MooseX/Runnable/Invocation/Plugin/Restart.pm +++ b/lib/MooseX/Runnable/Invocation/Plugin/Restart.pm @@ -27,9 +27,25 @@ has 'restart_signal' => ( default => sub { 'HUP' }, ); +sub _build_initargs_from_cmdline { + my ($class, @args) = @_; + confess 'Bad args passed to Restart plugin' + unless @args % 2 == 0; + + my %args = @args; + + my %res; + if(my $kill = $args{'--kill-signal'}){ + $res{kill_signal} = $kill; + } + if(my $res = $args{'--restart-signal'}){ + $res{restart_signal} = $res; + } + return \%res; +} + after '_restart_parent_setup' => sub { my $self = shift; - my ($kw, $rw); $kw = AnyEvent->signal( signal => $self->kill_signal, cb => sub { $self->kill_child;