ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/CondWebServer/server.py
Revision: 1.17
Committed: Mon Jul 21 14:31:32 2008 UTC (16 years, 9 months ago) by innocent
Content type: text/x-python
Branch: MAIN
CVS Tags: CONDAPP-1-5-1
Changes since 1.16: +1 -17 lines
Log Message:
restore old interface

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 innocent 1.17 from Applications import iov,globaltag,serviceMap
8 xiezhen 1.1 class Root(object):
9     @cherrypy.expose
10     def index(self):
11     """ Top level page
12     """
13     return "This is Cond DB Application Server"
14    
15     class Server(object):
16     def __init__(self):
17 xiezhen 1.13 self.__hostname='localhost'
18     self.__port=6789
19    
20 xiezhen 1.1 def start (self):
21     """Start server
22     """
23 xiezhen 1.13 parser=OptionParser()
24     parser.add_option("--port",action="store",dest="port",
25     help="port default 6789")
26     parser.add_option("--hostname",action="store",dest="hostname",
27     help="hostname default localhost")
28     (options, args) = parser.parse_args()
29 xiezhen 1.1 if options.hostname:
30 xiezhen 1.13 self.__hostname=options.hostname.strip(' ')
31 xiezhen 1.1 if options.port:
32 xiezhen 1.13 self.__port=int(options.port)
33 xiezhen 1.7
34 xiezhen 1.13 serverconfig={'global':{'server.socket_host':self.__hostname,'server.socket_port':self.__port,'server.environment':'production'}}
35 xiezhen 1.1 cherrypy.config.update(serverconfig)
36     cherrypy.tree.mount(Root(),script_name='/')
37     currentdir=os.path.dirname(os.path.abspath(__file__))
38     appconfigfile=os.path.join(currentdir,'config','application.conf')
39 xiezhen 1.7 #print 'appconfigfile',appconfigfile
40 xiezhen 1.1 cherrypy.tree.mount(iov.IOV(appconfigfile),script_name='/iov')
41 xiezhen 1.4 detconfigfile=os.path.join(currentdir,'config','detector.conf')
42 xiezhen 1.7 #print 'detconfigfile',detconfigfile
43 xiezhen 1.4 cherrypy.tree.mount(serviceMap.serviceMap(detconfigfile),script_name='/serviceMap')
44 xiezhen 1.8 cherrypy.tree.mount(globaltag.GlobalTag(appconfigfile),script_name='/globaltag')
45 xiezhen 1.1 cherrypy.server.quickstart()
46     cherrypy.engine.start()
47 xiezhen 1.13
48 xiezhen 1.1 if __name__ == '__main__':
49 xiezhen 1.14 fileHandle=open('pid.txt','w')
50     fileHandle.seek(0)
51     mypid=os.getpid()
52     fileHandle.write( str(mypid) )
53     fileHandle.close()
54 xiezhen 1.1 s=Server()
55     s.start()
56