开发者

Need to make my python web application self-monitoring (keep-alive) like a daemon

I wro开发者_StackOverflow中文版te my python web application with BaseHTTPServer. It is intended to run in localhost and serve localhost requests. It is intended to be hosted in a major VPS.

So I need some reliable way to keep it alive. Apache (and what's being served under it) can easily re-spawn when it's stopped. Similarly, I can make CRON do a "tomcat start" periodically, so that it starts up if it went down.

How do I make my python app also alive? I prefer something that responds to commands from CRON


First approach would be using supervisor. Another option is to use python-daemon and create a system-wide init-script that is started when system boots.

Also, for a quick hack - you can run the app inside the detachable shell like screen or tmux.


What you need is a process monitor, like the previously mentioned supervisord, but there's a lot of alternatives to choose from, like God, Monit, Upstart Et.c.

I've only used supervisord myself, and it has got an XMLRPC-interface which you could use from your other applications, i.e. something that's run by CRON.


Another option could be something along the lines of the self monitoring scripts (using subprocess) outlined here (this might not be the most comprehensive reference, but should get you on your way): http://www.tsheffler.com/blog/?p=377

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜