ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/CondWebServer/server.py
Revision: 1.31
Committed: Tue Sep 15 09:56:21 2009 UTC (15 years, 7 months ago) by xiezhen
Content type: text/x-python
Branch: MAIN
CVS Tags: CONDAPP-1-7-3, CONDAPP-1-7-2, HEAD
Changes since 1.30: +1 -2 lines
Log Message:
remove lumi service

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.31 from Applications import iovInspect,iovInspectOld,iovExport,globaltag,serviceMap
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.28 self.__oldappconfigfile='oldapplication.conf'
23 xiezhen 1.20 self.__appconfigfile='application.conf'
24 xiezhen 1.27 self.__detconfigfile='detector31x.conf'
25 xiezhen 1.28 self.__olddetconfigfile='detector.conf'
26 xiezhen 1.1 def start (self):
27     """Start server
28     """
29 xiezhen 1.13 parser=OptionParser()
30     parser.add_option("--port",action="store",dest="port",
31     help="port default 6789")
32     parser.add_option("--hostname",action="store",dest="hostname",
33     help="hostname default localhost")
34 xiezhen 1.20 parser.add_option("--configdir",action="store",dest="configdir",
35     help="configuration dir. Default to currentdir/config")
36 xiezhen 1.13 (options, args) = parser.parse_args()
37 xiezhen 1.1 if options.hostname:
38 xiezhen 1.13 self.__hostname=options.hostname.strip(' ')
39 xiezhen 1.1 if options.port:
40 xiezhen 1.13 self.__port=int(options.port)
41 xiezhen 1.20 if options.configdir:
42     self.__configdir = options.configdir.strip(' ')
43     else:
44     currentdir=os.path.dirname(os.path.abspath(__file__))
45     self.__configdir = os.path.join(currentdir,'config')
46 xiezhen 1.13 serverconfig={'global':{'server.socket_host':self.__hostname,'server.socket_port':self.__port,'server.environment':'production'}}
47 xiezhen 1.1 cherrypy.config.update(serverconfig)
48     cherrypy.tree.mount(Root(),script_name='/')
49 xiezhen 1.18
50     # here for the time being
51     self.__config=config.Config()
52 xiezhen 1.20 self.__config.from_ini(os.path.join(self.__configdir,self.__appconfigfile))
53     cherrypy.tree.mount(iovInspect.IOV(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/iov')
54 xiezhen 1.28 cherrypy.tree.mount(iovInspectOld.IOV(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/oldiov')
55 xiezhen 1.20 cherrypy.tree.mount(iovExport.IOV(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/exportIov')
56     cherrypy.tree.mount(serviceMap.serviceMap(os.path.join(self.__configdir,self.__detconfigfile)),script_name='/serviceMap')
57 xiezhen 1.28 cherrypy.tree.mount(serviceMap.serviceMap(os.path.join(self.__configdir,self.__olddetconfigfile)),script_name='/oldserviceMap')
58 xiezhen 1.20 cherrypy.tree.mount(globaltag.GlobalTag(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/globaltag')
59 xiezhen 1.1 cherrypy.server.quickstart()
60     cherrypy.engine.start()
61 xiezhen 1.13
62 xiezhen 1.1 if __name__ == '__main__':
63 xiezhen 1.14 fileHandle=open('pid.txt','w')
64     fileHandle.seek(0)
65     mypid=os.getpid()
66     fileHandle.write( str(mypid) )
67     fileHandle.close()
68 xiezhen 1.1 s=Server()
69     s.start()
70