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

John Napiorkowski jjn1056 at yahoo.com
Thu Jun 28 01:35:29 GMT 2007

--- Matt S Trout <dbix-class at trout.me.uk> wrote:

> On Wed, Jun 27, 2007 at 02:38:34PM -0700, John
> Napiorkowski wrote:
> > Hi,
> > 
> > I'm finding that the way I usually catch shutdown
> > signals to perform cleanup is not working. 
> Setting
> > %SIG handlers doesn't seem to do it and I'm not
> > finding that DESTROY methods are getting fired off
> in
> > the expected way.
> > 
> > For example if I set a $SIG{INT} handler in the
> > application class (MyApp.pm) that get's called if
> I am
> > running the development server foregrounded and
> the
> > interrupt it with a 'ctrl-c', but it doesn't get
> > called if the development server is deamonized and
> I
> > kill the process.  $SIG{QUIT} doesn't seem to do
> it. 
> > DESTROY doesn't seem to every get called.
> Add some better traces - I suspect this is either
> (a) a DBIC problem fixed
> in 0.08 or (b) a problem that isn't that you didn't
> give us a test case for
> yet :)

So you think this could be in DBIC?  I'll run the
whole thing in debug mode and see what I can find.

I guess I could use some help figuring out what we
would like the behavior to me.  For myself I'd like th
be able to respect SIGTERM (or whatever Apache sends
to modperl when it get's a stop command) and SIGHUP so
I can force a reload.

I got into this whole thing because I was writing some
code to create a tempdir for the template toolkit
cache files.  My admin want my application to kill up
more nicely after itself and I was tired of dealing
with permissions trouble in the /tmp directory when
several people are running the same instance of a
given catalyst application and all are trying to write
to the same tmp path.  I could handle this with local
config files for each developer but given the admin
request I figured it would be easier to just have TT
use a temporary directory.  Catalyst::Utils had a
nice, ready to go class2tempdir method but I just
found that when I killed the application the auto
cleanup just didn't seem to work.  So I ended up with
a bunch of tempdirs in /tmp which was the opposite

That lead me to playing with this.  If we can work out
what we want I will offer a test for Catalyst::Utils
and a patch for the desired behavior.

Thoughts appreciated!


> -- 
>       Matt S Trout       Need help with your
> Catalyst or DBIx::Class project?
>    Technical Director    Want a managed development
> or deployment platform?
>  Shadowcat Systems Ltd.  Contact mst (at)
> shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/            
> http://www.shadowcatsystems.co.uk/ 
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo:
> http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> Dev site: http://dev.catalyst.perl.org/

Need a vacation? Get great deals
to amazing places on Yahoo! Travel.

More information about the Catalyst mailing list