Skip to content
Snippets Groups Projects
Commit 03f3a016 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Update failover to lvalert_send

Failover to lvalert_send now uses new LVALert Python API, rather
than forking a Process to call the lvalert_send script.
parent 501f827d
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,8 @@ import logging
from multiprocessing import Process
import os
from subprocess import Popen, PIPE
from ligo.lvalert import LVAlertClient
from ligo.overseer.overseer_client import send_to_overseer
# Set up logger
......@@ -31,6 +33,21 @@ def send_with_lvalert_overseer(node_name, message, manager, port):
return True if rdict.get('success', None) is not None else False
def send_with_lvalert_client(node, message, server):
# Instantiate client
client = LVAlertClient(server=server)
# Client setup
client.connect(reattempt=False)
client.auto_reconnect = False
client.process(block=False)
# Send message
client.publish(node, message)
# OLD
def send_with_lvalert_send(node, message, server):
# Set up environment for running lvalert_send executable
......
......@@ -13,7 +13,7 @@ from events.permission_utils import is_external
from events.query import filter_for_labels
from events.shortcuts import is_event
from superevents.shortcuts import is_superevent
from .lvalert import send_with_lvalert_overseer, send_with_lvalert_send
from .lvalert import send_with_lvalert_overseer, send_with_lvalert_client
# Set up logger
logger = logging.getLogger(__name__)
......@@ -129,11 +129,11 @@ def issue_xmpp_alerts(event_or_superevent, alert_type, serialized_object,
"LVAlert Overseer failed, trying lvalert_send"))
# If not using LVAlert Overseer or if sending with overseer failed,
# use basic lvalert_send executable (gross)
# use basic lvalert-client send
if (not settings.USE_LVALERT_OVERSEER) or (not success):
success, err = send_with_lvalert_send(node_name, msg, server)
if not success:
try:
send_with_lvalert_client(node_name, msg, server)
except Exception as e:
logger.critical(("issue_xmpp_alerts: error sending "
"message with lvalert_send: {e}").format(e=err))
"message with lvalert client: {e}").format(e=e))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment