summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--takahe/settings/base.py2
-rw-r--r--takahe/settings/production.py2
-rw-r--r--takahe/settings/testing.py2
-rw-r--r--users/apps.py18
4 files changed, 14 insertions, 10 deletions
diff --git a/takahe/settings/base.py b/takahe/settings/base.py
index 660ec9f..0ab3035 100644
--- a/takahe/settings/base.py
+++ b/takahe/settings/base.py
@@ -118,5 +118,3 @@ AUTO_ADMIN_EMAIL: Optional[str] = None
STATOR_TOKEN: Optional[str] = None
SENTRY_ENABLED = False
-
-IN_TESTS = False
diff --git a/takahe/settings/production.py b/takahe/settings/production.py
index b23093f..b1034ef 100644
--- a/takahe/settings/production.py
+++ b/takahe/settings/production.py
@@ -10,6 +10,8 @@ DEBUG = bool(os.environ.get("TAKAHE__SECURITY_HAZARD__DEBUG", False))
# TODO: Allow better setting of allowed_hosts, if we need to
ALLOWED_HOSTS = ["*"]
+CONN_MAX_AGE = 60
+
### User-configurable options, pulled from the environment ###
# Secret key
diff --git a/takahe/settings/testing.py b/takahe/settings/testing.py
index c0af28b..39fda96 100644
--- a/takahe/settings/testing.py
+++ b/takahe/settings/testing.py
@@ -3,6 +3,4 @@ from .base import * # noqa
# Fixed secret key
SECRET_KEY = "testing_secret"
-IN_TESTS = True
-
MAIN_DOMAIN = "example.com"
diff --git a/users/apps.py b/users/apps.py
index 86a8eb3..67183ad 100644
--- a/users/apps.py
+++ b/users/apps.py
@@ -1,14 +1,20 @@
from django.apps import AppConfig
-from django.conf import settings
+from django.db.models.signals import post_migrate
class UsersConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "users"
- def ready(self) -> None:
- if not settings.IN_TESTS:
- # Generate the server actor keypair if needed
- from users.models import SystemActor
+ def data_init(self, **kwargs):
+ """
+ Runs after migrations or flushes to insert anything we need for first
+ boot (or post upgrade).
+ """
+ # Generate the server actor keypair if needed
+ from users.models import SystemActor
+
+ SystemActor.generate_keys_if_needed()
- SystemActor.generate_keys_if_needed()
+ def ready(self) -> None:
+ post_migrate.connect(self.data_init, sender=self)