diff --git a/SAS/ResourceAssignment/Services/src/RATaskSpecified.py b/SAS/ResourceAssignment/Services/src/RATaskSpecified.py index e05047d467f60f5276525967282e9b7e47d730cb..c57c6089bab81cfcb83a28678061ca3a88499426 100755 --- a/SAS/ResourceAssignment/Services/src/RATaskSpecified.py +++ b/SAS/ResourceAssignment/Services/src/RATaskSpecified.py @@ -226,3 +226,31 @@ class RATaskSpecified(OTDBBusListener): logger.info("Result sent") + +def main(): + import sys + import logging + from optparse import OptionParser + from lofar.common.util import waitForInterrupt + from lofar.sas.resourceassignment.rataskspecified.config import DEFAULT_NOTIFICATION_BUSNAME, RATASKSPECIFIED_NOTIFICATIONNAME + DEFAULT_OTDB_BUSNAME = 'lofar.otdb.status' + + logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) + + # Check the invocation arguments + parser = OptionParser("%prog [options]", + description="run the rataskspecified service") + parser.add_option("-o", "--otdb_bus", dest="otdb_busname", type="string", default=DEFAULT_OTDB_BUSNAME, + help="Bus or queue OTDB operates on") + parser.add_option("-b", "--notification_bus", dest="notification_bus", type="string", default=DEFAULT_NOTIFICATION_BUSNAME, + help="Bus or queue we publish resource requests on") + parser.add_option("-s", "--notification_subject", dest="notification_subject", type="string", default=RATASKSPECIFIED_NOTIFICATIONNAME, + help="The subject of the event messages which this service publishes") + (options, args) = parser.parse_args() + + with RATaskSpecified(RATASKSPECIFIED_NOTIFICATIONNAME, otdb_busname=options.otdb_busname, my_busname=options.notification_bus) as jts: + waitForInterrupt() + + +if __name__ == "__main__": + main() diff --git a/SAS/ResourceAssignment/Services/src/rataskspecifiedservice b/SAS/ResourceAssignment/Services/src/rataskspecifiedservice index 8140e688fd51f66c80af995b706424b8fc824f87..1faf339ea9018574e3d443db436b12681afb18ad 100644 --- a/SAS/ResourceAssignment/Services/src/rataskspecifiedservice +++ b/SAS/ResourceAssignment/Services/src/rataskspecifiedservice @@ -25,30 +25,8 @@ Daemon that listens to OTDB status changes to PRESCHEDULED, requests the parset of such jobs (+ their predecessors), and posts them on the bus. """ -from lofar.sas.resourceassignment.rataskspecified.RATaskSpecified import RATaskSpecified -from lofar.sas.resourceassignment.rataskspecified.config import DEFAULT_NOTIFICATION_BUSNAME, RATASKSPECIFIED_NOTIFICATIONNAME - -DEFAULT_OTDB_BUSNAME = 'lofar.otdb.status' +from lofar.sas.resourceassignment.rataskspecified.RATaskSpecified import main if __name__ == "__main__": - import sys - import logging - from optparse import OptionParser - from lofar.common.util import waitForInterrupt - - logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) - - # Check the invocation arguments - parser = OptionParser("%prog [options]", - description="run the rataskspecified service") - parser.add_option("-o", "--otdb_bus", dest="otdb_busname", type="string", default=DEFAULT_OTDB_BUSNAME, - help="Bus or queue OTDB operates on") - parser.add_option("-b", "--notification_bus", dest="notification_bus", type="string", default=DEFAULT_NOTIFICATION_BUSNAME, - help="Bus or queue we publish resource requests on") - parser.add_option("-s", "--notification_subject", dest="notification_subject", type="string", default=RATASKSPECIFIED_NOTIFICATIONNAME, - help="The subject of the event messages which this service publishes") - (options, args) = parser.parse_args() - - with RATaskSpecified(RATASKSPECIFIED_NOTIFICATIONNAME, otdb_busname=options.otdb_busname, my_busname=options.notification_bus) as jts: - waitForInterrupt() + main()