2019-02-08 13:57:59 +00:00
|
|
|
"""passbook Webserver management command"""
|
|
|
|
|
|
|
|
from logging import getLogger
|
|
|
|
|
2019-04-11 11:43:49 +00:00
|
|
|
from daphne.cli import CommandLineInterface
|
2019-02-08 13:57:59 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
2019-04-11 11:43:49 +00:00
|
|
|
from django.utils import autoreload
|
2019-02-08 13:57:59 +00:00
|
|
|
|
2019-04-11 11:43:49 +00:00
|
|
|
from passbook.lib.config import CONFIG
|
2019-02-08 13:57:59 +00:00
|
|
|
|
|
|
|
LOGGER = getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
"""Run CherryPy webserver"""
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2019-04-11 11:54:11 +00:00
|
|
|
"""passbook daphne server"""
|
2019-04-11 11:43:49 +00:00
|
|
|
autoreload.run_with_reloader(self.daphne_server)
|
|
|
|
|
|
|
|
def daphne_server(self):
|
|
|
|
"""Run daphne server within autoreload"""
|
|
|
|
autoreload.raise_last_exception()
|
2019-04-11 12:22:32 +00:00
|
|
|
CommandLineInterface().run([
|
|
|
|
'-p', str(CONFIG.y('web.port', 8000)),
|
|
|
|
'-b', CONFIG.y('web.listen', '0.0.0.0'), # nosec
|
|
|
|
'--access-log', '/dev/null',
|
2019-04-29 20:19:26 +00:00
|
|
|
'--application-close-timeout', '500',
|
2019-04-11 12:22:32 +00:00
|
|
|
'passbook.core.asgi:application'
|
|
|
|
])
|