This commit is contained in:
anhduy-tech
2026-03-06 09:51:53 +07:00
parent 39aea8784e
commit 3ece124848
487 changed files with 1851 additions and 108460 deletions

View File

@@ -6,19 +6,5 @@ class AppConfig(AppConfig):
name = 'app'
def ready(self):
import app.workflow_actions
from . import signals
signals.connect_signals()
# Sử dụng cache.add() của Django để tạo lock, đảm bảo chỉ một worker khởi động scheduler
try:
from django.core.cache import cache
# cache.add() là atomic, chỉ trả về True nếu key được tạo thành công
if cache.add("scheduler_lock", "locked", timeout=65):
from . import scheduler
scheduler.start()
print("Scheduler started by this worker.")
else:
print("Scheduler lock already held by another worker.")
except Exception as e:
print(f"Failed to start or check scheduler lock: {e}")
signals.connect_signals()