In our system, we have a test server, with several pyramid environments.
These environments are very similar to the production system (apache2 +
mod_wsgi...) but with debugging and template reloading enabled.
The problem arises with the "auto-reload" code. I've configured apache2
+ mod_wsgi in daemon mode, and only touching the wsgi file, is enough to
mod_wsgi reload the code (as Graham said in
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode)
To automatically reload without manually touching the file (developers
has restricted access to the filesystem in that server), I've created
the next solution.
Please, feel free to comment any possible problem with it.
Imagine the wsgi file is in /var/lib/wsgi/myapp.wsgi.
I've added the next code to the __init__.py
WSGIFILE = '/var/lib/wsgi/myapp.wsgi'
def touch_and_reload(event):
with file(WSGIFILE, 'a'):
os.utime(WSGIFILE, None)
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application. """
...
if settings['pyramid.reload_templates'] == 'true':
config.add_subscriber('myapp.touch_and_reload',
'pyramid.events.NewRequest')
config.scan()
...
This way the file is touched in every request, and every new python code
added, is automatically reloaded (Only for developing stages, of course :)
Greetings
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.