diff --git a/gracedb/alert.py b/gracedb/alert.py index 4e244792bf680743bd146bffbad829c7a7afd326..a422cf371803fd00729329698aa42e4268e6842f 100644 --- a/gracedb/alert.py +++ b/gracedb/alert.py @@ -8,10 +8,10 @@ from django.conf import settings import json import logging -#from hashlib import sha1 -#from ligo.overseer.client import send_to_overseer -#from multiprocessing import Process, Manager +from hashlib import sha1 +from ligo.overseer.client import send_to_overseer +from multiprocessing import Process, Manager log = logging.getLogger('gracedb.alert') @@ -150,23 +150,24 @@ def issueXMPPAlert(event, location, alert_type="new", description="", serialized msg = json.dumps(lva_data) log.debug("issueXMPPAlert: writing message %s" % msg) -# manager = Manager() + manager = Manager() for server in settings.ALERT_XMPP_SERVERS: + port = settings.LVALERT_OVERSEER_PORTS[server] for nodename in nodenames: -# # Calculate unique message_id and log -# message_id = sha1(nodename + msg).hexdigest() -# log.info("issueXMPPAlert: sending %s to node %s" % (message_id, nodename)) -# -# rdict = manager.dict() -# msg_dict = {'node_name': nodename, 'message': msg, 'action': 'push'} -# p = Process(target=send_to_overseer, args=(msg_dict, rdict, log, True)) -# p.start() -# p.join() -# -# if rdict.get('success', None): -# continue + # Calculate unique message_id and log + message_id = sha1(nodename + msg).hexdigest() + log.info("issueXMPPAlert: sending %s to node %s on %s" % (message_id, nodename, server)) + + rdict = manager.dict() + msg_dict = {'node_name': nodename, 'message': msg, 'action': 'push'} + p = Process(target=send_to_overseer, args=(msg_dict, rdict, log, True, port)) + p.start() + p.join() + + if rdict.get('success', None): + continue # If not success, we need to do this the old way. log.info("issueXMPPAlert: failover to lvalert_send") diff --git a/settings/branson.py b/settings/branson.py index 6d1c15a8c1988fd289c4293b688b7c5aa85e6e0c..0843ed9a0fe56ecf0f5728e6d044da7c222ea154 100644 --- a/settings/branson.py +++ b/settings/branson.py @@ -37,9 +37,14 @@ ALERT_TEST_EMAIL_FROM = "Dev Test Alert <root@moe.phys.uwm.edu>" ALERT_TEST_EMAIL_TO = [ "Branson Stephens <branson@gravity.phys.uwm.edu>", ] -ALERT_XMPP_SERVER = "jabber.phys.uwm.edu", -ALERT_XMPP_SERVERS = ["jabber.phys.uwm.edu",] -LVALERT_SEND_EXECUTABLE = '/home/branson/djangoenv/bin/lvalert_send' +ALERT_XMPP_SERVERS = ["lvalert-test.cgca.uwm.edu",] +LVALERT_SEND_EXECUTABLE = '/usr/bin/lvalert_send' + +# For each lvalert server, a separate instance of the lvalert_overseer +# must be running and listening on a distinct port. +LVALERT_OVERSEER_PORTS = { + 'lvalert-test.cgca.uwm.edu': 8001, +} EMBB_MAIL_ADDRESS = 'branson@moe.phys.uwm.edu' EMBB_SMTP_SERVER = 'localhost' diff --git a/settings/default.py b/settings/default.py index eb9ef95360c229fcabe183a117742bbc171537e1..3bf8e1fa5bd33d77b0f98ea0236a671288186f35 100644 --- a/settings/default.py +++ b/settings/default.py @@ -30,6 +30,12 @@ ALERT_TEST_EMAIL_TO = [ ALERT_XMPP_SERVERS = ["lvalert.cgca.uwm.edu"] LVALERT_SEND_EXECUTABLE = '/usr/bin/lvalert_send' +# For each lvalert server, a separate instance of the lvalert_overseer +# must be running and listening on a distinct port. +LVALERT_OVERSEER_PORTS = { + 'lvalert.cgca.uwm.edu': 8000, +} + EMBB_MAIL_ADDRESS = 'embb@gracedb.ligo.org' EMBB_SMTP_SERVER = 'localhost' EMBB_MAIL_ADMINS = ['branson@gravity.phys.uwm.edu','roy.williams@ligo.org',] diff --git a/settings/roy.py b/settings/roy.py index 0a549f3c541d498e9d907944a558b879e3215c78..549bc52f789ae9bd631e87a63342531cea6ca4c2 100644 --- a/settings/roy.py +++ b/settings/roy.py @@ -41,10 +41,15 @@ ALERT_TEST_EMAIL_TO = [ "Roy Williams <roy@caltech.edu>", ] -ALERT_XMPP_SERVER = 'jabber.phys.uwm.edu' -ALERT_XMPP_SERVERS = ['jabber.phys.uwm.edu',] +ALERT_XMPP_SERVERS = ['lvalert-test.cgca.uwm.edu',] LVALERT_SEND_EXECUTABLE = '/usr/bin/lvalert_send' +# For each lvalert server, a separate instance of the lvalert_overseer +# must be running and listening on a distinct port. +LVALERT_OVERSEER_PORTS = { + 'lvalert-test.cgca.uwm.edu': 8001, +} + EMBB_MAIL_ADDRESS = 'embb@embb-dev.ligo.caltech.edu' EMBB_SMTP_SERVER = 'acrux.ligo.caltech.edu' EMBB_MAIL_ADMINS = ['roy.williams@ligo.org',]