mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-13 13:33:42 +08:00
feat: Improve shutdown
* feat: Improve shutdown
This commit is contained in:
18
src/check.sh
18
src/check.sh
@@ -1,16 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
[ ! -f "/run/qemu.pid" ] && echo "QEMU not running yet.." && exit 0
|
||||
[ -f "/run/qemu.count" ] && echo "QEMU is shutting down.." && exit 1
|
||||
|
||||
file="/run/dsm.url"
|
||||
active="/run/qemu.pid"
|
||||
shutdown="/run/qemu.count"
|
||||
active_msg="QEMU not running yet.."
|
||||
shutdown_msg="QEMU is shutting down.."
|
||||
url="http://127.0.0.1:2210/read?command=10"
|
||||
|
||||
[ ! -f "$active" ] && echo "$active_msg" && exit 0
|
||||
[ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
|
||||
# Retrieve IP from guest VM for Docker healthcheck
|
||||
{ json=$(curl -m 20 -sk "$url"); rc=$?; } || :
|
||||
|
||||
[ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1
|
||||
(( rc != 0 )) && echo "Failed to connect to guest: curl error $rc" && exit 1
|
||||
|
||||
{ result=$(echo "$json" | jq -r '.status'); rc=$?; } || :
|
||||
@@ -36,11 +42,13 @@ if [ ! -f "$file" ]; then
|
||||
|
||||
fi
|
||||
|
||||
[ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1
|
||||
|
||||
location=$(cat "$file")
|
||||
|
||||
if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then
|
||||
echo "Failed to reach http://$location"
|
||||
exit 1
|
||||
[ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1
|
||||
echo "Failed to reach page at http://$location" && exit 1
|
||||
fi
|
||||
|
||||
echo "Healthcheck OK"
|
||||
|
||||
Reference in New Issue
Block a user