Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Force django to load the wsgi on startup

Mikail KOCAK997d091f5b07
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6de27e0054..c14b555c03 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -120,6 +120,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Ensure that a GraphQL query is a string - #4836 by @nix010
- Add ability to configure the password reset link - #4863 by @fowczarek
- Fixed a performance issue where Saleor would sometimes run huge, unneeded prefetches when resolving categories or collections - #5291 by @NyanKiyoshi
+- uWSGI now forces the django application to directly load on startup instead of being lazy - #5357 by @NyanKiyoshi
### Core
diff --git a/saleor/wsgi/__init__.py b/saleor/wsgi/__init__.py
index 1ecd7d8c96..2f94fb0873 100644
--- a/saleor/wsgi/__init__.py
+++ b/saleor/wsgi/__init__.py
@@ -12,6 +12,7 @@ middleware here, or combine a Django application with an application of another
framework.
"""
import os
+import sys
from django.core.wsgi import get_wsgi_application
@@ -27,3 +28,16 @@ application = get_wsgi_application()
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
application = health_check(application, "/health/")
+
+# Warm-up the django application instead of letting it lazy-load
+application(
+ {
+ "REQUEST_METHOD": "GET",
+ "SERVER_NAME": "127.0.0.1",
+ "REMOTE_ADDR": "127.0.0.1",
+ "SERVER_PORT": 80,
+ "PATH_INFO": "/graphql/",
+ "wsgi.input": sys.stdin,
+ },
+ lambda x, y: None,
+)