def test_start_queue_server():
    # Start Queue manager process, which will host the shared queue
    res = start_queue_manager(QueueHost,
                              QueuePortNr,
                              QueueAuthCode,
                              logger=logging.getLogger())
    assert res, "Could not create queue manager"
 def start_event_queue(self):
     """
     Starts a queue manager, if queue is None.
     Returns the queue.
     """
     q_ok = self._get_queue()
     if not q_ok:
         cfg = self.config
         hostname = cfg.queue_manager_hostname
         portnr = cfg.queue_manager_portnr
         auth_code = cfg.queue_manager_auth_code
         queues.start_queue_manager(hostname,
                                    portnr,
                                    auth_code,
                                    logger=None)
         return self._get_queue()
     return q_ok
Example #3
0
    def _get_queue_manager(self, cfg):
        """
        Tries to get an event queue. 
        If successful then returns the manager and the queue, 
        otherwise starts the new queue manager. 
        """
        hostname = cfg.queue_manager_hostname
        portnr = cfg.queue_manager_portnr
        auth_code = cfg.queue_manager_auth_code

        self.logger.debug(
            f"Getting shared event queue from {hostname}:{portnr}")
        queue = queues.get_event_queue(hostname, portnr, auth_code)
        if queue is None:
            self.logger.debug("Starting Queue Manager")
            self.queue_manager = queues.start_queue_manager(
                hostname, portnr, auth_code, self.logger)
            queue = queues.get_event_queue(hostname, portnr, auth_code)
            if queue is not None:
                self.logger.debug("Got event queue from Queue Manager")
            return queue
        else:
            return queue
Example #4
0
def test_start_queue_server():
    # Start Queue manager process, which will host the shared queue
    proc = start_queue_manager(QueueHost, QueuePortNr, QueueAuthCode)
    assert proc is not None, "Could not create Queue manager"
Example #5
0
    epilog = "\nStart event queue manager\n"

    parser = argparse.ArgumentParser(prog=f"{in_args[0]}", description=description, usage=usage, epilog=epilog)
    parser.add_argument("-c", "--config", dest="config_file", type=str, help="Configuration file")
    parser.add_argument("-H", "--host", dest="hostname", type=str, help="Host name")
    parser.add_argument("-p", "--port", dest="portnr", type=str, help="Port number")

    try:
        return parser.parse_args(in_args[1:])
    except:
        # parser.print_help()
        sys.exit(0)


if __name__ == "__main__":
    args = _parseArguments(sys.argv)
    cfg = ConfigClass(args.config_file)
    cfg.properties["want_multiprocessing"] = True
    hostname = cfg.queue_manager_hostname if args.hostname is None else args.hostname
    portnr = cfg.queue_manager_portnr if args.portnr is None else args.portnr
    auth_code = cfg.queue_manager_auth_code

    if queues.get_event_queue(hostname, portnr, auth_code) is not None:
        print("Queue Manager is already running\n")
    else:
        queue = queues.start_queue_manager(hostname, portnr, auth_code, logger=logging.getLogger())

        print(f"Hostname = {hostname}\nPort nr = {portnr}\n")
        print("Started Queue Manager.")
    os._exit(0)