X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FObject%2FRemote%2FWatchDog.pm;h=170b2b2151447993d9da08a15c64bc7a6341ce45;hb=f129bfaf05b1ae0e2e2992cad47a70482dec9885;hp=2a3fc6160e82ac089339c6e4227a270f2de030e7;hpb=c824fdf36c659b3b6dbafe23a3021f2b1d6eeb3f;p=scpubgit%2FObject-Remote.git diff --git a/lib/Object/Remote/WatchDog.pm b/lib/Object/Remote/WatchDog.pm index 2a3fc61..170b2b2 100644 --- a/lib/Object/Remote/WatchDog.pm +++ b/lib/Object/Remote/WatchDog.pm @@ -4,16 +4,6 @@ use Object::Remote::MiniLoop; use Object::Remote::Logging qw ( :log :dlog ); use Moo; -BEGIN { - $SIG{ALRM} = sub { - #if the Watchdog is killing the process we don't want any chance of the - #process not actually exiting and die could be caught by an eval which - #doesn't do us any good - log_error { sprintf("Watchdog has expired, terminating the process at file %s line %s", __FILE__, __LINE__ + 1); }; - exit(1); - }; -}; - has timeout => ( is => 'ro', required => 1 ); around new => sub { @@ -28,6 +18,15 @@ around new => sub { #start the watchdog sub BUILD { my ($self) = @_; + + $SIG{ALRM} = sub { + #if the Watchdog is killing the process we don't want any chance of the + #process not actually exiting and die could be caught by an eval which + #doesn't do us any good + log_error { sprintf("Watchdog has expired, terminating the process at file %s line %s", __FILE__, __LINE__ + 1); }; + exit(1); + }; + Dlog_debug { "Initializing watchdog with timeout of $_ seconds" } $self->timeout; alarm($self->timeout); }