#!/usr/bin/env python3 import socket import time def loop(): print("Waiting for ClickHouse and Postgres to be ready") try: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect(('clickhouse', 9000)) print("Clickhouse is ready") with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect(('db', 5432)) print("Postgres is ready") except ConnectionRefusedError as e: time.sleep(5) loop() loop()