add support for a passive monitor url
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Morgan McMillian 2023-03-17 12:23:07 -07:00
parent a3e56a4e26
commit 5916dd1508

View file

@ -347,6 +347,9 @@ def on_close(ws, status_code, msg):
def on_open(ws):
def run(*args):
if "MONITOR_URL" in config:
r = requests.get(config['MONITOR_URL'])
step = 0
while not _error.isSet():
qmsg = Queue.query.one_or_none()
if qmsg:
@ -354,7 +357,12 @@ def on_open(ws):
db_session.delete(qmsg)
db_session.commit()
ws.send(".")
time.sleep(3)
if "MONITOR_URL" in config and step > 5:
r = requests.get(config['MONITOR_URL'])
step = 0
elif "MONITOR_URL" in config:
step += 1
time.sleep(5)
logger.debug("*** terminate ***")
t = threading.Thread(target=run)