-
Notifications
You must be signed in to change notification settings - Fork 1
/
umbheki.py~
executable file
·53 lines (45 loc) · 1.36 KB
/
umbheki.py~
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
from daemon3x import daemon
import time, sys
import os
import logging
from umb import main
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch.setFormatter(formatter)
logger.addHandler(ch)
main_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
sys.path.append(main_dir + "/umb")
class Umbheki(daemon):
def foobar(self):
print self.id()
def run(self):
self.umbheki = main.Umbheki()
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
print 'daemon stopped by user request. shutting down.'
sys.stop()
if __name__ == "__main__":
umbheki = Umbheki('/tmp/umbheki.pid')
if len(sys.argv) == 2:
if 'start' == sys.argv[1]:
umbheki.start()
elif 'debugstart' == sys.argv[1]:
umbheki.debugmodus=True
umbheki.start()
elif 'stop' == sys.argv[1]:
umbheki.stop()
elif 'restart' == sys.argv[1]:
umbheki.restart()
else:
print "Unknown command"
sys.exit(2)
sys.exit(0)
else:
print "usage: %s start|debugstart|stop|restart" % sys.argv[0]
sys.exit(2)