Don't start rspamd until admin is up and working

main
Florent Daigniere 2 years ago
parent d8cf0c3848
commit 89f7d983b4

@ -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"])

Loading…
Cancel
Save