I think that a simple system cron is the most reliable (per minute, per hour, per day). Then use some type of locking mechanism in your web2py script (either database or file). For example:
locked = db((db.report_queue.status=='SystemLock')).select().first() if not locked: locked = db.report_queue.insert(status='SystemLock') db.commit() # and so on On Apr 28, 5:04 am, teemu <teemu.kuulas...@gmail.com> wrote: > Hi, > > I would like to know what would be the best way to start background > process in production environment. I have implemented background > process by using the web2py book chapter as a template > ("http://www.web2py.com/book/default/chapter/04#Background-Processes-and-Task-..."). > I start background process manually on my development machine > (Winddows 7, web2py webserver) and it works great. Now it is time to > publish my app on production server (debian linux, apache2, mod_wsgi). > I was wondering what would be the best and the most simple way to > start this background process together with apache/mod_wsgi? Ideal > solution would be cross-platform compatible but this is not > mandatory. > > As far as i know there are several different options but I do not know > what is the best and what are advantages and disadvantages of > different methods: > > 1) manually from shell: > - laborious and should be done upon every server reboot > > 2) init script: > - good option and can be integrated with apache2 init script > > 3) web2py-cron-@reboot: > - is this even possible or recommended? However, this would be the > only cross-platform alternative > > 3) system cron: > - cron job could check if background process is still running and > restart process if it has been crashed > > How have you guys done this? Any suggestions? > > Teemu