core: revert to cherrypy for main webserver and use daphne only for app_gw
This commit is contained in:
parent
4d0148193f
commit
ed25801e6e
|
@ -0,0 +1,30 @@
|
|||
"""passbook app_gw webserver management command"""
|
||||
|
||||
from logging import getLogger
|
||||
|
||||
from daphne.cli import CommandLineInterface
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import autoreload
|
||||
|
||||
from passbook.lib.config import CONFIG
|
||||
|
||||
LOGGER = getLogger(__name__)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Run Daphne Webserver for app_gw"""
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""passbook daphne server"""
|
||||
autoreload.run_with_reloader(self.daphne_server)
|
||||
|
||||
def daphne_server(self):
|
||||
"""Run daphne server within autoreload"""
|
||||
autoreload.raise_last_exception()
|
||||
CommandLineInterface().run([
|
||||
'-p', str(CONFIG.y('app_gw.port', 8000)),
|
||||
'-b', CONFIG.y('app_gw.listen', '0.0.0.0'), # nosec
|
||||
'--access-log', '/dev/null',
|
||||
'--application-close-timeout', '500',
|
||||
'passbook.app_gw.asgi:application'
|
||||
])
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
from logging import getLogger
|
||||
|
||||
from daphne.cli import CommandLineInterface
|
||||
import cherrypy
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import autoreload
|
||||
|
||||
from passbook.lib.config import CONFIG
|
||||
from passbook.root.wsgi import application
|
||||
|
||||
LOGGER = getLogger(__name__)
|
||||
|
||||
|
@ -15,16 +16,21 @@ class Command(BaseCommand):
|
|||
"""Run CherryPy webserver"""
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""passbook daphne server"""
|
||||
autoreload.run_with_reloader(self.daphne_server)
|
||||
|
||||
def daphne_server(self):
|
||||
"""Run daphne server within autoreload"""
|
||||
autoreload.raise_last_exception()
|
||||
CommandLineInterface().run([
|
||||
'-p', str(CONFIG.y('web.port', 8000)),
|
||||
'-b', CONFIG.y('web.listen', '0.0.0.0'), # nosec
|
||||
'--access-log', '/dev/null',
|
||||
'--application-close-timeout', '500',
|
||||
'passbook.root.asgi:application'
|
||||
])
|
||||
"""passbook cherrypy server"""
|
||||
cherrypy.config.update(CONFIG.get('web'))
|
||||
cherrypy.tree.graft(application, '/')
|
||||
# Mount NullObject to serve static files
|
||||
cherrypy.tree.mount(None, settings.STATIC_URL, config={
|
||||
'/': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': settings.STATIC_ROOT,
|
||||
'tools.expires.on': True,
|
||||
'tools.expires.secs': 86400,
|
||||
'tools.gzip.on': True,
|
||||
}
|
||||
})
|
||||
cherrypy.engine.start()
|
||||
for file in CONFIG.loaded_file:
|
||||
cherrypy.engine.autoreload.files.add(file)
|
||||
LOGGER.info("Added '%s' to autoreload triggers", file)
|
||||
cherrypy.engine.block()
|
||||
|
|
|
@ -23,9 +23,13 @@ email:
|
|||
use_ssl: false
|
||||
from: passbook <passbook@domain.tld>
|
||||
web:
|
||||
listen: 0.0.0.0
|
||||
port: 8000
|
||||
threads: 30
|
||||
server.socket_host: 0.0.0.0
|
||||
server.socket_port: 8000
|
||||
server.thread_pool: 20
|
||||
log.screen: false
|
||||
log.access_file: ''
|
||||
log.error_file: ''
|
||||
|
||||
debug: false
|
||||
secure_proxy_header:
|
||||
HTTP_X_FORWARDED_PROTO: https
|
||||
|
@ -96,3 +100,6 @@ saml_idp:
|
|||
types:
|
||||
- passbook.saml_idp.processors.generic
|
||||
- passbook.saml_idp.processors.salesforce
|
||||
app_gw:
|
||||
listen: 0.0.0.0
|
||||
port: 8000
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
celery
|
||||
colorlog
|
||||
cherrypy
|
||||
django-ipware
|
||||
django-model-utils
|
||||
django-redis
|
||||
|
@ -11,5 +12,4 @@ psycopg2
|
|||
PyYAML
|
||||
sentry-sdk
|
||||
pip
|
||||
whitenoise
|
||||
urllib3<1.25,>=1.21.1
|
||||
|
|
|
@ -122,7 +122,6 @@ CACHES = {
|
|||
|
||||
MIDDLEWARE = [
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'passbook.app_gw.middleware.ApplicationGatewayMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
|
@ -239,7 +238,6 @@ if not DEBUG:
|
|||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
with CONFIG.cd('log'):
|
||||
LOGGING = {
|
||||
|
|
Reference in New Issue