ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/CondWebServer/server.py
Revision: 1.26
Committed: Tue Jun 16 16:54:16 2009 UTC (15 years, 10 months ago) by xiezhen
Content type: text/x-python
Branch: MAIN
Changes since 1.25: +1 -6 lines
Log Message:
cleanup

File Contents

# User Rev Content
1 xiezhen 1.1 import os, sys
2 xiezhen 1.14 import coral
3 xiezhen 1.1 import cherrypy
4     from optparse import OptionParser
5 xiezhen 1.13 import DLFCN
6     sys.setdlopenflags(DLFCN.RTLD_GLOBAL+DLFCN.RTLD_LAZY)
7 xiezhen 1.24 from Applications import iovInspect, iovExport, globaltag,serviceMap,luminosityApp
8 xiezhen 1.18 from Common import config
9 xiezhen 1.23 #from pluginCondDBPyInterface import *
10 xiezhen 1.22 os.environ["QUIET_ASSERT"]='yes'
11 xiezhen 1.1 class Root(object):
12     @cherrypy.expose
13     def index(self):
14     """ Top level page
15     """
16     return "This is Cond DB Application Server"
17    
18     class Server(object):
19     def __init__(self):
20 xiezhen 1.13 self.__hostname='localhost'
21     self.__port=6789
22 xiezhen 1.20 self.__appconfigfile='application.conf'
23     self.__detconfigfile='detector.conf'
24 xiezhen 1.1 def start (self):
25     """Start server
26     """
27 xiezhen 1.13 parser=OptionParser()
28     parser.add_option("--port",action="store",dest="port",
29     help="port default 6789")
30     parser.add_option("--hostname",action="store",dest="hostname",
31     help="hostname default localhost")
32 xiezhen 1.20 parser.add_option("--configdir",action="store",dest="configdir",
33     help="configuration dir. Default to currentdir/config")
34 xiezhen 1.13 (options, args) = parser.parse_args()
35 xiezhen 1.1 if options.hostname:
36 xiezhen 1.13 self.__hostname=options.hostname.strip(' ')
37 xiezhen 1.1 if options.port:
38 xiezhen 1.13 self.__port=int(options.port)
39 xiezhen 1.20 if options.configdir:
40     self.__configdir = options.configdir.strip(' ')
41     else:
42     currentdir=os.path.dirname(os.path.abspath(__file__))
43     self.__configdir = os.path.join(currentdir,'config')
44 xiezhen 1.13 serverconfig={'global':{'server.socket_host':self.__hostname,'server.socket_port':self.__port,'server.environment':'production'}}
45 xiezhen 1.1 cherrypy.config.update(serverconfig)
46     cherrypy.tree.mount(Root(),script_name='/')
47 xiezhen 1.18
48     # here for the time being
49     self.__config=config.Config()
50 xiezhen 1.20 self.__config.from_ini(os.path.join(self.__configdir,self.__appconfigfile))
51     cherrypy.tree.mount(iovInspect.IOV(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/iov')
52     cherrypy.tree.mount(iovExport.IOV(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/exportIov')
53     cherrypy.tree.mount(serviceMap.serviceMap(os.path.join(self.__configdir,self.__detconfigfile)),script_name='/serviceMap')
54     cherrypy.tree.mount(globaltag.GlobalTag(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/globaltag')
55 xiezhen 1.26 cherrypy.tree.mount(luminosityApp.lumi(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/lumi')
56 xiezhen 1.1 cherrypy.server.quickstart()
57     cherrypy.engine.start()
58 xiezhen 1.13
59 xiezhen 1.1 if __name__ == '__main__':
60 xiezhen 1.14 fileHandle=open('pid.txt','w')
61     fileHandle.seek(0)
62     mypid=os.getpid()
63     fileHandle.write( str(mypid) )
64     fileHandle.close()
65 xiezhen 1.1 s=Server()
66     s.start()
67