webpy uwsgi deploy with cron tasks?

110 views
Skip to first unread message

He Shiming

unread,
Mar 21, 2012, 12:42:54 PM3/21/12
to web.py
Dear Community,

I wrote an app using webpy (webpy.org). Part of this web app is
recurring background tasks for statistical functions. I used
``APScheduler`` python library to perform cron style schedules.
Because ``app.run()`` let webpy run in standalone mode during
development. This setup worked out fine.

However, when it's deployed, I discovered that APScheduler no longer
functions. Deployment procedure pretty much follows
http://fartersoft.com/blog/2012/02/10/deployment-of-web-py-applications-using-uwsgi-and-nginx-on-ubuntu/
. My entry point program still prints successful scheduling logs. But
it appears that uwsgi will suspend the running webpy app (making the
thread suspended) when no requests are received. If I refresh a page,
APScheduler will wakeup, printing a few
``WARNING:apscheduler.scheduler:Run time of job "worker (trigger:
cron[...], next run at: ..)" was missed by 0:04:36.389705`` messages.
They are not running according to the schedule.

My question is, how do I schedule cron style tasks when deploying a
uwsgi webpy app. I saw uwsgi itself has cron support. But I wonder how
I can mix it with my app, like APScheduler (or replace it)? The tasks
depends on a few modules and dynamic properties of the app, so they
can't be easily converted into standalone .py programs.

Thanks in advance.

Best regards,
He Shiming

Andrey Kuzmin

unread,
Mar 22, 2012, 3:40:22 AM3/22/12
to we...@googlegroups.com
You can create cron job as http get request on some uri, and then curl it from cron.
Reply all
Reply to author
Forward
0 new messages