|
@@ -16,11 +16,6 @@ from io import BufferedWriter
|
16
|
16
|
from lodel.context import LodelContext
|
17
|
17
|
from lodel.context import ContextError
|
18
|
18
|
|
19
|
|
-##@brief On wich addr we want to bind. '' mean all interfaces
|
20
|
|
-LISTEN_ADDR = ''
|
21
|
|
-##@brief Listening socket port
|
22
|
|
-LISTEN_PORT = 1337
|
23
|
|
-
|
24
|
19
|
##@brief Set the poll interval to detect shutdown requests (do not work)
|
25
|
20
|
SHUTDOWN_POLL_INTERVAL = 0.1 # <-- No impact because of ForkingTCPServer bug
|
26
|
21
|
|
|
@@ -86,6 +81,10 @@ class LodelWSGIHandler(wsgiref.simple_server.WSGIRequestHandler):
|
86
|
81
|
#in a child process
|
87
|
82
|
class ForkingWSGIServer(
|
88
|
83
|
wsgiref.simple_server.WSGIServer, socketserver.ForkingTCPServer):
|
|
84
|
+
|
|
85
|
+ ##@brief static property indicating the max number of childs allowed
|
|
86
|
+ max_children = 40
|
|
87
|
+
|
89
|
88
|
##@brief Custom reimplementation of shutdown method in order to ensure
|
90
|
89
|
#that we close all listening sockets
|
91
|
90
|
#
|
|
@@ -152,9 +151,10 @@ def wsgi_router(env, start_response):
|
152
|
151
|
|
153
|
152
|
##@brief Starts the server until a SIGINT is received
|
154
|
153
|
def main_loop():
|
155
|
|
- #Init app cache
|
156
|
|
- listen_addr = LISTEN_ADDR
|
157
|
|
- listen_port = LISTEN_PORT
|
|
154
|
+ LodelContext.expose_modules(globals(), {'lodel.settings': ['Settings']})
|
|
155
|
+ ForkingWSGIServer.max_children = Settings.server.max_children
|
|
156
|
+ listen_addr = Settings.server.listen_address
|
|
157
|
+ listen_port = Settings.server.listen_port
|
158
|
158
|
server = wsgiref.simple_server.make_server(
|
159
|
159
|
listen_addr, listen_port, wsgi_router,
|
160
|
160
|
server_class=ForkingWSGIServer, handler_class = LodelWSGIHandler)
|