ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/CondWebServer/server.py
Revision: 1.18
Committed: Thu Dec 11 17:20:38 2008 UTC (16 years, 4 months ago) by xiezhen
Content type: text/x-python
Branch: MAIN
Changes since 1.17: +21 -3 lines
Log Message:
integrated with new 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.18 from Applications import iovInspect, iovExport, payload, globaltag,serviceMap
8     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.18 self.__configfile='application.conf'
23 xiezhen 1.13
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.18 parser.add_option("--configfile",action="store",dest="configfile",
33     help="configuration file default application.conf")
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.18 #if options.configfile:
40     # self.__configfile = options.configfile.strip(' ')
41 xiezhen 1.7
42 xiezhen 1.13 serverconfig={'global':{'server.socket_host':self.__hostname,'server.socket_port':self.__port,'server.environment':'production'}}
43 xiezhen 1.1 cherrypy.config.update(serverconfig)
44     cherrypy.tree.mount(Root(),script_name='/')
45     currentdir=os.path.dirname(os.path.abspath(__file__))
46     appconfigfile=os.path.join(currentdir,'config','application.conf')
47 xiezhen 1.18
48     # here for the time being
49     self.__config=config.Config()
50     self.__config.from_ini(appconfigfile)
51     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     cherrypy.tree.mount(iovInspect.IOV(appconfigfile),script_name='/iov')
58     cherrypy.tree.mount(iovExport.IOV(appconfigfile),script_name='/exportIov')
59 xiezhen 1.4 detconfigfile=os.path.join(currentdir,'config','detector.conf')
60 xiezhen 1.7 #print 'detconfigfile',detconfigfile
61 xiezhen 1.4 cherrypy.tree.mount(serviceMap.serviceMap(detconfigfile),script_name='/serviceMap')
62 xiezhen 1.8 cherrypy.tree.mount(globaltag.GlobalTag(appconfigfile),script_name='/globaltag')
63 xiezhen 1.1 cherrypy.server.quickstart()
64     cherrypy.engine.start()
65 xiezhen 1.13
66 xiezhen 1.1 if __name__ == '__main__':
67 xiezhen 1.14 fileHandle=open('pid.txt','w')
68     fileHandle.seek(0)
69     mypid=os.getpid()
70     fileHandle.write( str(mypid) )
71     fileHandle.close()
72 xiezhen 1.1 s=Server()
73     s.start()
74