Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions authentik/root/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@
},
),
("dramatiq.results.middleware.Results", {"store_results": True}),
("authentik.tasks.middleware.StartupSignalsMiddleware", {}),
("authentik.tasks.middleware.CurrentTask", {}),
("authentik.tasks.middleware.TenantMiddleware", {}),
("authentik.tasks.middleware.ModelDataMiddleware", {}),
Expand Down
9 changes: 9 additions & 0 deletions authentik/tasks/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from authentik.events.models import Event, EventAction
from authentik.lib.sentry import should_ignore_exception
from authentik.lib.utils.reflection import class_to_path
from authentik.root.signals import post_startup, pre_startup, startup
from authentik.tasks.models import Task, TaskLog, TaskStatus, WorkerStatus
from authentik.tenants.models import Tenant
from authentik.tenants.utils import get_current_tenant
Expand All @@ -32,6 +33,14 @@
DB_ERRORS = (OperationalError, Error)


class StartupSignalsMiddleware(Middleware):
def after_process_boot(self, broker: Broker):
_startup_sender = type("WorkerStartup", (object,), {})
pre_startup.send(sender=_startup_sender)
startup.send(sender=_startup_sender)
post_startup.send(sender=_startup_sender)


class CurrentTask(BaseCurrentTask):
@classmethod
def get_task(cls) -> Task:
Expand Down
7 changes: 0 additions & 7 deletions authentik/tasks/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@
import django # noqa: E402

django.setup()

from authentik.root.signals import post_startup, pre_startup, startup # noqa: E402

_startup_sender = type("WorkerStartup", (object,), {})
pre_startup.send(sender=_startup_sender)
startup.send(sender=_startup_sender)
post_startup.send(sender=_startup_sender)
Loading