ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/CondWebServer/server.py
Revision: 1.20
Committed: Mon Feb 9 15:30:18 2009 UTC (16 years, 2 months ago) by xiezhen
Content type: text/x-python
Branch: MAIN
CVS Tags: CONDAPP-1-6-3b, CONDAPP-1-6-3, CONDAPP-1-6-2
Changes since 1.19: +14 -16 lines
Log Message:
remove dependency on cmssw version

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.19 from Applications import iovInspect, iovExport, globaltag,serviceMap
8 xiezhen 1.18 from Common import config
9     from pluginCondDBPyInterface import *
10    
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 xiezhen 1.18 self.__authpath=self.__config.common.auth_path
52     os.environ["CORAL_AUTH_PATH"] = self.__authpath
53     print "auth path ", os.environ["CORAL_AUTH_PATH"]
54     # this one shall be alive all the time...
55     self.__cmsframe = FWIncantation
56    
57 xiezhen 1.20 cherrypy.tree.mount(iovInspect.IOV(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/iov')
58     cherrypy.tree.mount(iovExport.IOV(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/exportIov')
59     cherrypy.tree.mount(serviceMap.serviceMap(os.path.join(self.__configdir,self.__detconfigfile)),script_name='/serviceMap')
60     cherrypy.tree.mount(globaltag.GlobalTag(os.path.join(self.__configdir,self.__appconfigfile)),script_name='/globaltag')
61 xiezhen 1.1 cherrypy.server.quickstart()
62     cherrypy.engine.start()
63 xiezhen 1.13
64 xiezhen 1.1 if __name__ == '__main__':
65 xiezhen 1.14 fileHandle=open('pid.txt','w')
66     fileHandle.seek(0)
67     mypid=os.getpid()
68     fileHandle.write( str(mypid) )
69     fileHandle.close()
70 xiezhen 1.1 s=Server()
71     s.start()
72