forked from FFM/Collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
executable file
·48 lines (42 loc) · 893 Bytes
/
run.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
import settings
import os
import sys
def cold():
"""Starts the Collectd"""
from collectd.collectd import Collectd
c=Collectd(settings)
pid=os.fork()
if not pid:
c.collect()
else:
if len(sys.argv)>2:
f=open(sys.argv[2],"w")
f.write("%s"%pid)
f.close()
def rsvr():
""" Runs the development server """
sys.argv.pop()
import api.api
api.api.do()
def fcgi():
""" Starts the FastCGI server """
sys.argv.pop()
import api.api
api.api.fcgi()
commands={"collectd":cold,
"devserver":rsvr,
"fastcgi":fcgi,
}
if __name__=="__main__":
try:
cmd=sys.argv[1]
except IndexError:
cmd=""
if cmd not in commands.keys():
print """Collectd management console....
Usage: python run.py command"""
print """Known commands: """
for (k,v) in commands.items():
print "%s: %s"%(k,v.__doc__)
else:
commands[cmd]()