Files
zulip/zerver/management/commands/send_zulip_update_announcements.py
Alex Vandiver 11dd6791c4 management: Provide a common lockfile dir, and a decorator for it.
Factor out the repeated pattern of taking a lock, or immediately
aborting with a message if it cannot be acquired.  The exit code in
that situation is changed to be exit code 1, rather than the successful
0; we are likely missing new work since that process started.

We move the lockfiles to a common directory under `/srv/zulip-locks`
rather than muddy up `/home/zulip/deployments`.
2024-04-24 14:40:28 -07:00

25 lines
806 B
Python

from argparse import ArgumentParser
from typing import Any
from typing_extensions import override
from zerver.lib.management import ZulipBaseCommand, abort_unless_locked
from zerver.lib.zulip_update_announcements import send_zulip_update_announcements
class Command(ZulipBaseCommand):
help = """Script to send zulip update announcements to realms."""
@override
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument(
"--skip-delay",
action="store_true",
help="Immediately send updates if 'zulip_update_announcements_stream' is configured.",
)
@override
@abort_unless_locked
def handle(self, *args: Any, **options: Any) -> None:
send_zulip_update_announcements(skip_delay=options["skip_delay"])