From f7713d84a3127a76eb714431f801f294f22020d8 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Wed, 7 Jan 2015 11:38:22 +0100 Subject: [PATCH] handled exception if the docker deamon does not expose events on the REST-API --- nginx_proxy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nginx_proxy.py b/nginx_proxy.py index 6cb549f..89ace5a 100755 --- a/nginx_proxy.py +++ b/nginx_proxy.py @@ -1,6 +1,7 @@ #!/usr/bin/python3.4 import os +import sys import http.client import json import signal @@ -118,7 +119,12 @@ if not os.path.exists(target_path): pid = get_pid() conn = http.client.HTTPConnection("localhost:2375") -conn.request("GET", "/events") +try: + conn.request("GET", "/events") +except ConnectionRefusedError: + print('Docker does not expose events on its REST-API. Perhaps it is not running?') + sys.exit(-1) + response = conn.getresponse() events = ""