This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/core/management/commands/web.py

31 lines
898 B
Python
Raw Normal View History

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):
"""passbook cherrypy 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()
with CONFIG.cd('web'):
CommandLineInterface().run([
'-p', str(CONFIG.get('port', 8000)),
'-b', CONFIG.get('listen', '0.0.0.0'), # nosec
'--access-log', '/dev/null',
'passbook.core.asgi:application'
])