-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* main: root: fix missing imports after #9081 (#9106) root: move database calls from ready() to dedicated startup signal (#9081) web: fix console log leftover (#9096) web: bump the eslint group in /web with 2 updates (#9098) core: bump twilio from 9.0.2 to 9.0.3 (#9103) web: bump the eslint group in /tests/wdio with 2 updates (#9099) core: bump drf-spectacular from 0.27.1 to 0.27.2 (#9100) core: bump django-model-utils from 4.4.0 to 4.5.0 (#9101) core: bump ruff from 0.3.4 to 0.3.5 (#9102) website/docs: update notes on SECRET_KEY (#9091) web: fix broken locale compile (#9095) website/integrations: add outline knowledge base (#8786) website/docs: fix typo (#9082) website/docs: email stage: fix example translation error (#9048)
- Loading branch information
Showing
57 changed files
with
1,148 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
"""custom runserver command""" | ||
|
||
from typing import TextIO | ||
|
||
from daphne.management.commands.runserver import Command as RunServer | ||
from daphne.server import Server | ||
|
||
from authentik.root.signals import post_startup, pre_startup, startup | ||
|
||
|
||
class SignalServer(Server): | ||
"""Server which signals back to authentik when it finished starting up""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
def ready_callable(): | ||
pre_startup.send(sender=self) | ||
startup.send(sender=self) | ||
post_startup.send(sender=self) | ||
|
||
self.ready_callable = ready_callable | ||
|
||
|
||
class Command(RunServer): | ||
"""custom runserver command, which doesn't show the misleading django startup message""" | ||
|
||
def on_bind(self, server_port): | ||
pass | ||
server_cls = SignalServer | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
# Redirect standard stdout banner from Daphne into the void | ||
# as there are a couple more steps that happen before startup is fully done | ||
self.stdout = TextIO() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from datetime import timedelta | ||
|
||
from django.core.signals import Signal | ||
from django.dispatch import receiver | ||
from django.utils.timezone import now | ||
from structlog.stdlib import get_logger | ||
|
||
# Signal dispatched before actual startup trigger | ||
pre_startup = Signal() | ||
# Signal dispatched which should trigger all startup logic | ||
startup = Signal() | ||
# Signal dispatched after the startup logic | ||
post_startup = Signal() | ||
|
||
LOGGER = get_logger() | ||
|
||
|
||
@receiver(pre_startup) | ||
def pre_startup_log(sender, **_): | ||
sender._start_time = now() | ||
|
||
|
||
@receiver(post_startup) | ||
def post_startup_log(sender, **_): | ||
took: timedelta = now() - sender._start_time | ||
LOGGER.info("authentik Core Worker finished starting", took_s=took.total_seconds()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.