From 319092ea606cf55e7d0fba14b191711e89e7444a Mon Sep 17 00:00:00 2001 From: kaliko Date: Fri, 27 May 2011 17:47:14 +0200 Subject: [PATCH] Add example script --- doc/examples/daemon-example.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 doc/examples/daemon-example.py diff --git a/doc/examples/daemon-example.py b/doc/examples/daemon-example.py new file mode 100755 index 0000000..2baca82 --- /dev/null +++ b/doc/examples/daemon-example.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +import sys, time +from daemon import Daemon + +class MyDaemon(Daemon): + def run(self): + while True: + time.sleep(1) + +if __name__ == "__main__": + daemon = MyDaemon('/tmp/daemon-example.pid') + if len(sys.argv) == 2: + if 'start' == sys.argv[1]: + daemon.start() + elif 'stop' == sys.argv[1]: + daemon.stop() + elif 'restart' == sys.argv[1]: + daemon.restart() + else: + print "Unknown command" + sys.exit(2) + sys.exit(0) + else: + print "usage: %s start|stop|restart" % sys.argv[0] + sys.exit(2) -- 2.39.5