Browse Source

HEALTHCHECK operation

Signed-off-by: Erik Hollensbe <[email protected]>
Erik Hollensbe 3 years ago
parent
commit
d52ebaa412
2 changed files with 10 additions and 7 deletions
  1. 2 0
      Dockerfile.release
  2. 8 7
      entrypoint.sh.release

+ 2 - 0
Dockerfile.release

@@ -22,5 +22,7 @@ RUN rm -rf /var/lib/zerotier-one
 COPY entrypoint.sh.release /entrypoint.sh
 RUN chmod 755 /entrypoint.sh
 
+HEALTHCHECK CMD bash /healthcheck.sh
+
 CMD []
 ENTRYPOINT ["/entrypoint.sh"]

+ 8 - 7
entrypoint.sh.release

@@ -65,15 +65,16 @@ do
   sleep 1
 done
 
-echo "Ensuring status for networks: $@"
+echo "Writing healthcheck for networks: $@"
 
-for i in "$@"
+cat >/healthcheck.sh <<EOF
+#!/bin/bash
+for i in $@
 do
-  while [ "$(zerotier-cli get $i status)" != "OK" ]
-  do 
-    echo "joining $i failed (are they added in central?); trying again in 1s"
-    sleep 1
-  done
+  [ "\$(zerotier-cli get \$i status)" = "OK" ] || exit 1
 done
+EOF
+
+chmod +x /healthcheck.sh
 
 sleep infinity