import sys import os import os path from cogen web import wsgi from co

 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
44
45
46
47
48
import sys
import os
import os.path
from cogen.web import wsgi
from cogen.web.async import sync_input
from cogen.common import *
path = os.path.dirname(os.path.realpath(__file__))
if not path in sys.path:
sys.path.insert(0, path)
from django.core.handlers.wsgi import WSGIHandler
_application = WSGIHandler()
def application(environ, start_response):
os.environ['DJANGO_SETTINGS_MODULE'] = 'asd_settings'
return _application(environ, start_response)
def application2(environ, start_response):
os.environ['DJANGO_SETTINGS_MODULE'] = 'huis_settings'
return _application(environ, start_response)
m = Scheduler(default_priority=priority.LAST, default_timeout=15)
server = wsgi.WSGIServer(
('localhost', 9000),
sync_input(application), #!!! load middleware for wsgi.input
m,
server_name='localhost'
)
server2 = wsgi.WSGIServer(
('localhost', 9001),
sync_input(application2), #!!! load middleware for wsgi.input
m,
server_name='localhost2'
)
m.add(server.serve)
m.add(server2.serve)
print 'run server'
try:
m.run()
except (KeyboardInterrupt, SystemExit):
pass