forked from meetbill/MyPythonLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_daemon.py
More file actions
34 lines (30 loc) · 763 Bytes
/
run_daemon.py
File metadata and controls
34 lines (30 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
import Queue
import threading
import sys, time
import urllib2
import json
import agent
from daemon import Daemon
pid_file = "/var/run/test.pid"
class MyDaemon(Daemon):
def run(self):
agent.startTh()
if __name__ == "__main__":
######################################
# edit this code
daemon = MyDaemon(pid_file)
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)