heartbeat for long running web.py process

57 views
Skip to first unread message

Patrick Dunnigan

unread,
Mar 12, 2012, 12:39:07 PM3/12/12
to we...@googlegroups.com
We have built a web service with web.py as such:

...
        app = web.application(urls, globals(), autoreload=False)
        app.run()
...

What I would like to do is register a heartbeat (either to a file or database) every x seconds. I see that the web.background was moved out of the main line of code, this kinda looked like what I needed. 

Any suggestions on doing something like this on an interval (in a loop) in web.py?

Thanks 

Anand Chitipothu

unread,
Mar 12, 2012, 12:49:04 PM3/12/12
to we...@googlegroups.com
తేదిన 12 మార్చి 2012 12:39 సా, Patrick Dunnigan
<patrick.m...@gmail.com> వ్రాశారు:

web.background is deprecated. This task looks ideal for a cron job.

Anand

Patrick Dunnigan

unread,
Mar 12, 2012, 1:23:34 PM3/12/12
to we...@googlegroups.com
The point is to log a heartbeat from the running web.py process. 

If the web.py server goes down, the heartbeat gets stale and actions can be taken. 

Anand Chitipothu

unread,
Mar 12, 2012, 8:07:58 PM3/12/12
to we...@googlegroups.com
తేదిన 12 మార్చి 2012 10:23 ఉ, Patrick Dunnigan

<patrick.m...@gmail.com> వ్రాశారు:
> The point is to log a heartbeat from the running web.py process.
>
> If the web.py server goes down, the heartbeat gets stale and actions can be
> taken.

You can write a handler for /heartbeat and call it from a cronjob periodically.

Anand

DavidA

unread,
Mar 13, 2012, 8:18:11 AM3/13/12
to web.py
I would agree with Anand that it's better to set up a cron job to run
every minute or so and hit a url that returns some status (or logs the
status to a file). This is what I've done in the past. I'd also put
the cron job (or Windows Scheduled Task) on a different machine.

The best way to see if a web server is running properly is to fetch a
url. A background process that logs something might tell you if the
process is running but it won't tell you if the server is accepting
requests.

On Mar 12, 8:07 pm, Anand Chitipothu <anandol...@gmail.com> wrote:
> తేదిన 12 మార్చి 2012 10:23 ఉ, Patrick Dunnigan
> <patrick.m.dunni...@gmail.com> వ్రాశారు:
Reply all
Reply to author
Forward
0 new messages