refactor: enhance webhook delivery queue processing with configurable blocking
This commit is contained in:
43
scripts/rq
Executable file
43
scripts/rq
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
"""Top-level RQ helper entrypoint."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT_DIR))
|
||||
|
||||
from scripts.rq_webhook import cmd_worker
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="Generic background worker helpers.")
|
||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
worker_parser = subparsers.add_parser(
|
||||
"worker",
|
||||
help="Run background queue worker loop.",
|
||||
)
|
||||
worker_parser.add_argument(
|
||||
"--interval-seconds",
|
||||
type=float,
|
||||
default=float(os.environ.get("WEBHOOK_WORKER_INTERVAL_SECONDS", "2")),
|
||||
help="Seconds to wait for queue work before returning when idle.",
|
||||
)
|
||||
worker_parser.set_defaults(func=cmd_worker)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args()
|
||||
sys.exit(args.func(args))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user