mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
manage.py: Save an extra Django startup by converting one script to a library.
This saves us from spending 200-250ms of CPU time importing Django again just to log that we're running a management command. On `scripts/restart-server`, this saves us from one thundering herd of Django startups when all the queue workers are restarted; but there's still the Django startup for the `manage.py` process itself for each worker, so on a machine with e.g. 2 (virtual) cores the restart is still painful.
This commit is contained in:
@@ -4,8 +4,6 @@ from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(BASE_DIR)
|
||||
@@ -20,10 +18,9 @@ if __name__ == "__main__":
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import CommandError
|
||||
from scripts.lib.zulip_tools import log_management_command
|
||||
|
||||
logger = logging.getLogger("zulip.management")
|
||||
subprocess.check_call([os.path.join(BASE_DIR, "scripts", "lib", "log-management-command"),
|
||||
" ".join(sys.argv)])
|
||||
log_management_command(" ".join(sys.argv), settings.MANAGEMENT_LOG_PATH)
|
||||
|
||||
if "--no-traceback" not in sys.argv and len(sys.argv) > 1:
|
||||
sys.argv.append("--traceback")
|
||||
|
Reference in New Issue
Block a user