diff --git a/core/rspamd/start.py b/core/rspamd/start.py index fcb33a97..b03a602f 100755 --- a/core/rspamd/start.py +++ b/core/rspamd/start.py @@ -3,7 +3,9 @@ import os import glob import logging as log +import requests import sys +import time from socrate import system, conf log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) @@ -19,5 +21,16 @@ if os.environ.get("ANTIVIRUS") == 'clamav': for rspamd_file in glob.glob("/conf/*"): conf.jinja(rspamd_file, os.environ, os.path.join("/etc/rspamd/local.d", os.path.basename(rspamd_file))) +# Admin may not be up just yet +healthcheck = f'http://{os.environ["ADMIN_ADDRESS"]}/internal/rspamd/local_domains' +while True: + time.sleep(1) + try: + if requests.get(healthcheck,timeout=2).ok: + break + except: + pass + print("Admin is not up just yet, retrying in 1 second") + # Run rspamd os.execv("/usr/sbin/rspamd", ["rspamd", "-i", "-f"])