From 048bfad7433c32a718cc733881d4cff49a35667b Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 2 Mar 2016 09:40:37 -0800 Subject: [PATCH 1/2] Pause 2 seconds before starting nginx This hopefully lets nginx start after dockergen is done. This prevents nginx from failing when there is a custom nginx config that depends on things in the generated nginx config. Fixes: GH-378 --- Procfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Procfile b/Procfile index 8547156..11e26f2 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -nginx: nginx -dockergen: docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf +nginx: sleep 2; echo "Starting nginx..."; nginx +dockergen: echo "Starting docker-gen..."; docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf From 46684b7a668a433c3c3c7343f64d68bea096a7d4 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 2 Mar 2016 10:05:48 -0800 Subject: [PATCH 2/2] Check for presence iof dockergen.conf instead of hard-coded sleep of 2 seconds which is not super reliable --- Procfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Procfile b/Procfile index 11e26f2..4e1fb1f 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -nginx: sleep 2; echo "Starting nginx..."; nginx -dockergen: echo "Starting docker-gen..."; docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf +nginx: while [ ! -f /etc/nginx/conf.d/dockergen.conf ]; do echo "Waiting for dockergen.conf to appear before starting nginx..."; sleep 1; done; echo "Starting nginx..."; nginx +dockergen: echo "Starting docker-gen..."; docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/dockergen.conf