1 |
xiezhen |
1.1 |
import os, sys
|
2 |
|
|
import cherrypy
|
3 |
|
|
from optparse import OptionParser
|
4 |
xiezhen |
1.13 |
import DLFCN
|
5 |
|
|
sys.setdlopenflags(DLFCN.RTLD_GLOBAL+DLFCN.RTLD_LAZY)
|
6 |
|
|
from Applications import iov,globaltag,serviceMap
|
7 |
xiezhen |
1.1 |
class Root(object):
|
8 |
|
|
@cherrypy.expose
|
9 |
|
|
def index(self):
|
10 |
|
|
""" Top level page
|
11 |
|
|
"""
|
12 |
|
|
return "This is Cond DB Application Server"
|
13 |
|
|
|
14 |
|
|
class Server(object):
|
15 |
|
|
def __init__(self):
|
16 |
xiezhen |
1.13 |
self.__hostname='localhost'
|
17 |
|
|
self.__port=6789
|
18 |
|
|
|
19 |
xiezhen |
1.1 |
def start (self):
|
20 |
|
|
"""Start server
|
21 |
|
|
"""
|
22 |
xiezhen |
1.13 |
parser=OptionParser()
|
23 |
|
|
parser.add_option("--port",action="store",dest="port",
|
24 |
|
|
help="port default 6789")
|
25 |
|
|
parser.add_option("--hostname",action="store",dest="hostname",
|
26 |
|
|
help="hostname default localhost")
|
27 |
|
|
(options, args) = parser.parse_args()
|
28 |
xiezhen |
1.1 |
if options.hostname:
|
29 |
xiezhen |
1.13 |
self.__hostname=options.hostname.strip(' ')
|
30 |
xiezhen |
1.1 |
if options.port:
|
31 |
xiezhen |
1.13 |
self.__port=int(options.port)
|
32 |
xiezhen |
1.7 |
|
33 |
xiezhen |
1.13 |
serverconfig={'global':{'server.socket_host':self.__hostname,'server.socket_port':self.__port,'server.environment':'production'}}
|
34 |
xiezhen |
1.1 |
cherrypy.config.update(serverconfig)
|
35 |
|
|
cherrypy.tree.mount(Root(),script_name='/')
|
36 |
|
|
currentdir=os.path.dirname(os.path.abspath(__file__))
|
37 |
|
|
appconfigfile=os.path.join(currentdir,'config','application.conf')
|
38 |
xiezhen |
1.7 |
#print 'appconfigfile',appconfigfile
|
39 |
xiezhen |
1.1 |
cherrypy.tree.mount(iov.IOV(appconfigfile),script_name='/iov')
|
40 |
xiezhen |
1.4 |
detconfigfile=os.path.join(currentdir,'config','detector.conf')
|
41 |
xiezhen |
1.7 |
#print 'detconfigfile',detconfigfile
|
42 |
xiezhen |
1.4 |
cherrypy.tree.mount(serviceMap.serviceMap(detconfigfile),script_name='/serviceMap')
|
43 |
xiezhen |
1.8 |
cherrypy.tree.mount(globaltag.GlobalTag(appconfigfile),script_name='/globaltag')
|
44 |
xiezhen |
1.1 |
cherrypy.server.quickstart()
|
45 |
|
|
cherrypy.engine.start()
|
46 |
xiezhen |
1.13 |
|
47 |
xiezhen |
1.1 |
if __name__ == '__main__':
|
48 |
|
|
s=Server()
|
49 |
|
|
s.start()
|
50 |
|
|
|