-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcherry.py
52 lines (36 loc) · 1.27 KB
/
cherry.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
44
45
46
47
48
49
50
51
52
"""
WSGI config for conf project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""
import os
import cherrypy
from django.conf import settings
from django.core.wsgi import get_wsgi_application
from paste.translogger import TransLogger
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "animehub.settings.dev")
app = get_wsgi_application()
logged_app = TransLogger(app, format=None, setup_console_handler=True)
# Prevent cherrypy from automatically reloading.
cherrypy.config.update({'global': {'engine.autoreload.on': False}})
static_config = {
'tools.staticdir.on': True,
'tools.staticdir.dir': settings.STATIC_ROOT
}
# Mount the application
cherrypy.tree.mount(None, settings.STATIC_URL, {'/': static_config})
cherrypy.tree.graft(logged_app, "/")
# Unsubscribe the default server
cherrypy.server.unsubscribe()
# Instantiate a new server object
server = cherrypy._cpserver.Server()
# Configure the server object
server.socket_host = "0.0.0.0"
server.socket_port = int(os.environ.get('PORT', 8080))
server.thread_pool = 30
cherrypy.log.screen = True
# Subscribe this server
server.subscribe()
cherrypy.engine.start()
cherrypy.engine.block()