-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_service.py
executable file
·47 lines (33 loc) · 1.23 KB
/
http_service.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
#!/usr/bin/env python
#-*- coding:utf-8 -*-
""" Usage: http_service.py [--config=<config>] [--engine=<engine>] [<port>] """
import os
import docopt
import goldmine
options = docopt.docopt(__doc__)
if options["--config"]:
configfile = options["--config"]
else:
path = os.path.dirname(os.path.abspath(__file__))
configfile = path + '/config.ini'
config = goldmine.config(configfile)
if options["<port>"]:
config["services"]["http"]["port"] = options["<port>"]
if options["--engine"]:
config["services"]["http"]["engine"] = options["--engine"]
from goldmine.controller import Controller
from goldmine.services.http import HTTPService
from goldmine.protocols.json import JSONRPCProtocol
from goldmine.protocols.rest import RESTProtocol
info = (config["services"]["http"]["port"], config["services"]["http"]["engine"])
goldmine.debug("http_service.py starting on port %s with %s" % info, module="http-service")
HTTPService(
{
"/service": JSONRPCProtocol(Controller),
"/json": JSONRPCProtocol(Controller),
"/rest": RESTProtocol(Controller),
},
server=config["services"]["http"]["engine"],
port=int(config["services"]["http"]["port"]),
webroot=config["services"]["http"]["webroot"]
)