开发者

python unix service library

I have a command-line python app that is a service - i.e. it waits for connections and does stuff when asked, like webserver. There's python-daemon library for dealing with all the issues of detaching from the terminal, forking, etc. but I'd like to go a bit further - to have the开发者_如何学JAVA program do the following:

  1. Know if it's already running or not (by checking the PID file)
  2. When called with 'start' option it should start the daemon if it's not running, or tell the PID of existing one and exit if running.
  3. When called with 'stop' option it should kill the running instance if it exist, and clean the PID file.
  4. When called with 'restart' option it should do 'stop', then 'start'
  5. When called with 'status' option it should display the PID of running instance or nothing if it's not running.

If that looks like standard Unix service - that's exactly what I want. Is there a Python library that implements such pattern?


I've used this recipe. Works pretty good.

http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜