tags:

views:

79

answers:

1

I have a Python 2.6 web app built on Pylons 0.9.7. The code in my controller only runs the first time a client requests it, which is fair enough, but is there any way I can run some code as soon as the server starts and is ready to accept requests, without waiting until a request is actually received?

+1  A: 

It's an environment setting, if that's what you're asking.

Specifically: lib/app_globals, modify _ _ init _ _ (). (Ignore the spaces there, silly emboldening function!)

See: http://pylonshq.com/docs/en/0.9.7/configuration/#environment

Alternative methods are getting your helper script (that which is launching the server) to run it prior to running the site.

Swixel
Thanks. This is a start, but it runs before the server is listening, not after.
Evgeny
You could make a PID file (or similar) to run on 'first instance', or use a launch script to run something, I guess. From a purely 'web' point of view Pylons didn't offer much in the way of 'post-launch' support (at least not when I was last into playing with it).
Swixel