[Catalyst] Proper way to perform cleanups on server shutdown?

Jonathan T. Rockway jon at jrock.us
Wed Jul 11 17:50:22 GMT 2007


On Wed, Jul 11, 2007 at 09:03:29AM -0700, John Napiorkowski wrote:
> I can demonstrate this by placing an END block in my
> root modules (the "MyApp.pm" module)
> 
> END {
>   print "got END BLOCK!\n";
> }
> 
> This will never run under the conditions I have
> described.
> 
> HOWEVER, if I set SIG handlers manually like so:
> 
> $SIG{INT} = sub { print "got INT!\n" };
> $SIG{TERM} = sub { print "got TERM!\n" };
> 
> END {
>   print "got END BLOCK!\n";
> }
> 
> Then the END block does run.

Is this different from what you would expect?

try:

  $ perl -e 'END { print "going away\n" }; sleep 1 while(1);' 
  ^C
  $ _

compared to:

  $ perl -e 'END { print "going away\n" }'
  going away
  $ _ 

>From what I've observed, a signal won't trigger END blocks even
outside of Catalyst.

Regards,
Jonathan Rockway



More information about the Catalyst mailing list