authentik.core.management.commands.dev_server

custom runserver command

 1"""custom runserver command"""
 2
 3from io import StringIO
 4
 5from daphne.management.commands.runserver import Command as RunServer
 6from daphne.server import Server
 7
 8from authentik.lib.debug import start_debug_server
 9from authentik.root.signals import post_startup, pre_startup, startup
10
11
12class SignalServer(Server):
13    """Server which signals back to authentik when it finished starting up"""
14
15    def __init__(self, *args, **kwargs):
16        super().__init__(*args, **kwargs)
17        start_debug_server()
18
19        def ready_callable():
20            pre_startup.send(sender=self)
21            startup.send(sender=self)
22            post_startup.send(sender=self)
23
24        self.ready_callable = ready_callable
25
26
27class Command(RunServer):
28    """custom runserver command, which doesn't show the misleading django startup message"""
29
30    server_cls = SignalServer
31
32    def __init__(self, *args, **kwargs):
33        super().__init__(*args, **kwargs)
34        # Redirect standard stdout banner from Daphne into the void
35        # as there are a couple more steps that happen before startup is fully done
36        self.stdout = StringIO()
class SignalServer(daphne.server.Server):
13class SignalServer(Server):
14    """Server which signals back to authentik when it finished starting up"""
15
16    def __init__(self, *args, **kwargs):
17        super().__init__(*args, **kwargs)
18        start_debug_server()
19
20        def ready_callable():
21            pre_startup.send(sender=self)
22            startup.send(sender=self)
23            post_startup.send(sender=self)
24
25        self.ready_callable = ready_callable

Server which signals back to authentik when it finished starting up

SignalServer(*args, **kwargs)
16    def __init__(self, *args, **kwargs):
17        super().__init__(*args, **kwargs)
18        start_debug_server()
19
20        def ready_callable():
21            pre_startup.send(sender=self)
22            startup.send(sender=self)
23            post_startup.send(sender=self)
24
25        self.ready_callable = ready_callable
ready_callable
class Command(daphne.management.commands.runserver.Command):
28class Command(RunServer):
29    """custom runserver command, which doesn't show the misleading django startup message"""
30
31    server_cls = SignalServer
32
33    def __init__(self, *args, **kwargs):
34        super().__init__(*args, **kwargs)
35        # Redirect standard stdout banner from Daphne into the void
36        # as there are a couple more steps that happen before startup is fully done
37        self.stdout = StringIO()

custom runserver command, which doesn't show the misleading django startup message

Command(*args, **kwargs)
33    def __init__(self, *args, **kwargs):
34        super().__init__(*args, **kwargs)
35        # Redirect standard stdout banner from Daphne into the void
36        # as there are a couple more steps that happen before startup is fully done
37        self.stdout = StringIO()
server_cls = <class 'SignalServer'>
stdout