-
Notifications
You must be signed in to change notification settings - Fork 2
/
wsgi.py
43 lines (29 loc) · 1.11 KB
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from wsgiref.simple_server import make_server
from RequestHandler import RequestHandler
from beaker.middleware import SessionMiddleware
from Config import Config
from PidLock import PidLock
import threading
try:
#requestHandler = RequestHandler()
#Enable beaker sessions
#RequestHandler= SessionMiddleware(RequestHandler, Config.session_opts)
#RequestHandler.__init__ = SessionMiddleware(RequestHandler.__init__, Config.session_opts)
RequestHandler.handleNewRequest = SessionMiddleware(RequestHandler.handleNewRequest, Config.session_opts)
#Make a file to show we're running
with PidLock() as lockFile:
#Make server
httpd = make_server('',8000,RequestHandler.handleNewRequest)
print "Serving on port 8000"
#Create and set the shutdown thread for the wsgi server
RequestHandler.initializeStatics( httpd, threading.Thread(target=RequestHandler.shutdown) )
#SERVE!!!
print "Serving forever!"
httpd.serve_forever(5) #poll_interval as arg
print "Bye!"
except Exception, e:
print "An exception occured while trying to launch wsgi:",e
finally:
f=open("wsgi_pid.lock", "w")
f.write("0")
f.close()