summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/bitbake-prserv
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/bin/bitbake-prserv')
-rwxr-xr-xbitbake/bin/bitbake-prserv55
1 files changed, 55 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-prserv b/bitbake/bin/bitbake-prserv
new file mode 100755
index 0000000..a8d7acb
--- /dev/null
+++ b/bitbake/bin/bitbake-prserv
@@ -0,0 +1,55 @@
1#!/usr/bin/env python
2import os
3import sys,logging
4import optparse
5
6sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),'lib'))
7
8import prserv
9import prserv.serv
10
11__version__="1.0.0"
12
13PRHOST_DEFAULT='0.0.0.0'
14PRPORT_DEFAULT=8585
15
16def main():
17 parser = optparse.OptionParser(
18 version="Bitbake PR Service Core version %s, %%prog version %s" % (prserv.__version__, __version__),
19 usage = "%prog < --start | --stop > [options]")
20
21 parser.add_option("-f", "--file", help="database filename(default: prserv.sqlite3)", action="store",
22 dest="dbfile", type="string", default="prserv.sqlite3")
23 parser.add_option("-l", "--log", help="log filename(default: prserv.log)", action="store",
24 dest="logfile", type="string", default="prserv.log")
25 parser.add_option("--loglevel", help="logging level, i.e. CRITICAL, ERROR, WARNING, INFO, DEBUG",
26 action = "store", type="string", dest="loglevel", default = "INFO")
27 parser.add_option("--start", help="start daemon",
28 action="store_true", dest="start")
29 parser.add_option("--stop", help="stop daemon",
30 action="store_true", dest="stop")
31 parser.add_option("--host", help="ip address to bind", action="store",
32 dest="host", type="string", default=PRHOST_DEFAULT)
33 parser.add_option("--port", help="port number(default: 8585)", action="store",
34 dest="port", type="int", default=PRPORT_DEFAULT)
35
36 options, args = parser.parse_args(sys.argv)
37 prserv.init_logger(os.path.abspath(options.logfile),options.loglevel)
38
39 if options.start:
40 ret=prserv.serv.start_daemon(options.dbfile, options.host, options.port,os.path.abspath(options.logfile))
41 elif options.stop:
42 ret=prserv.serv.stop_daemon(options.host, options.port)
43 else:
44 ret=parser.print_help()
45 return ret
46
47if __name__ == "__main__":
48 try:
49 ret = main()
50 except Exception:
51 ret = 1
52 import traceback
53 traceback.print_exc(5)
54 sys.exit(ret)
55