mirror of https://github.com/zulip/zulip.git
zulip_updates: Prevent racing with self using a lock.
This commit is contained in:
parent
5c5e6b8cc5
commit
342a9bd5cd
|
@ -1,8 +1,11 @@
|
|||
from argparse import ArgumentParser
|
||||
from typing import Any
|
||||
|
||||
from django.conf import settings
|
||||
from typing_extensions import override
|
||||
|
||||
from scripts.lib.zulip_tools import ENDC, WARNING
|
||||
from zerver.lib.context_managers import lockfile_nonblocking
|
||||
from zerver.lib.management import ZulipBaseCommand
|
||||
from zerver.lib.zulip_update_announcements import send_zulip_update_announcements
|
||||
|
||||
|
@ -20,4 +23,13 @@ class Command(ZulipBaseCommand):
|
|||
|
||||
@override
|
||||
def handle(self, *args: Any, **options: Any) -> None:
|
||||
send_zulip_update_announcements(skip_delay=options["skip_delay"])
|
||||
with lockfile_nonblocking(
|
||||
settings.ZULIP_UPDATE_ANNOUNCEMENTS_LOCK_FILE,
|
||||
) as lock_acquired:
|
||||
if lock_acquired:
|
||||
send_zulip_update_announcements(skip_delay=options["skip_delay"])
|
||||
else:
|
||||
print(
|
||||
f"{WARNING}Update announcements lock {settings.ZULIP_UPDATE_ANNOUNCEMENTS_LOCK_FILE} is unavailable;"
|
||||
f" exiting.{ENDC}"
|
||||
)
|
||||
|
|
|
@ -699,6 +699,9 @@ AUTH_LOG_PATH = zulip_path("/var/log/zulip/auth.log")
|
|||
SCIM_LOG_PATH = zulip_path("/var/log/zulip/scim.log")
|
||||
|
||||
ZULIP_WORKER_TEST_FILE = zulip_path("/var/log/zulip/zulip-worker-test-file")
|
||||
ZULIP_UPDATE_ANNOUNCEMENTS_LOCK_FILE = zulip_path(
|
||||
"/home/zulip/deployments/zulip_update_announcements.lock"
|
||||
)
|
||||
|
||||
|
||||
if IS_WORKER:
|
||||
|
|
Loading…
Reference in New Issue