From ee90cf8b5a93d6d9008d500621332b002451adfe Mon Sep 17 00:00:00 2001 From: Julian Geywitz Date: Fri, 16 Oct 2020 09:42:36 +0200 Subject: [PATCH] Gracefully shutdown the cluster when the container stops --- start-gnt-rapi.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/start-gnt-rapi.sh b/start-gnt-rapi.sh index 9658efc..515780c 100755 --- a/start-gnt-rapi.sh +++ b/start-gnt-rapi.sh @@ -1,3 +1,14 @@ #!/bin/bash -su --preserve-environment -s /bin/bash -c '/usr/bin/python /usr/sbin/ganeti-rapi --debug -b 0.0.0.0 -f' gnt-rapi +cleanup() { + echo "Stopping Cluster..." + /opt/ganeti-vcluster/stop-all +} + +trap 'true' SIGTERM + +su --preserve-environment -s /bin/bash -c '/usr/bin/python /usr/sbin/ganeti-rapi --debug -b 0.0.0.0 -f' gnt-rapi & + +wait $! + +cleanup