diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c259055d..291f904bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - The broker name can now be amqps (with ssl) or amqp (without ssl). - The encryption key will now be created when running merlin config. +- The merlin info connection check will now enforce a minute timeout + check for the server connections. ### Fixed - Added a check for initial running workers when using merlin monitor to diff --git a/docs/source/merlin_commands.rst b/docs/source/merlin_commands.rst index 5ece0de55..0a85b2562 100644 --- a/docs/source/merlin_commands.rst +++ b/docs/source/merlin_commands.rst @@ -96,7 +96,9 @@ Information (``merlin info``) ----------------------------- Information about your merlin and python configuration can be printed out by using the -``info`` command. This is helpful for debugging. +``info`` command. This is helpful for debugging. Included in this command +is a server check which will check for server connections. The connection +check will timeout after 60 seconds. .. code:: bash diff --git a/merlin/display.py b/merlin/display.py index 45b8a31f6..b5b746ce3 100644 --- a/merlin/display.py +++ b/merlin/display.py @@ -33,6 +33,8 @@ """ import pprint import subprocess +import time +from multiprocessing import Process from kombu import Connection from tabulate import tabulate @@ -53,11 +55,22 @@ def check_server_access(sconf): print("-" * 28) excpts = {} + connect_timeout = 60 for s in servers: if s in sconf: try: conn = Connection(sconf[s]) - conn.connect() + conn_check = Process(target=conn.connect) + conn_check.start() + counter = 0 + while conn_check.is_alive(): + time.sleep(1) + counter += 1 + if counter > connect_timeout: + conn_check.kill() + raise Exception( + f"Connection was killed due to timeout ({connect_timeout}s)" + ) conn.release() print(f"{s} connection: OK") except Exception as e: