feat: Show daemon log

* feat: Show daemon log
This commit is contained in:
Kroese
2023-12-28 17:58:07 +01:00
committed by GitHub
parent d09588b915
commit 973efa2d27
7 changed files with 33 additions and 24 deletions

View File

@@ -11,7 +11,8 @@ QEMU_TERM=""
QEMU_PORT=7100
QEMU_TIMEOUT=50
QEMU_PID="/run/qemu.pid"
QEMU_COUNT="/run/qemu.count"
QEMU_LOG="/run/qemu.log"
QEMU_END="/run/qemu.end"
if [[ "$KVM" == [Nn]* ]]; then
API_TIMEOUT=$(( API_TIMEOUT*2 ))
@@ -19,7 +20,9 @@ if [[ "$KVM" == [Nn]* ]]; then
fi
rm -f "$QEMU_PID"
rm -f "$QEMU_COUNT"
rm -f "$QEMU_LOG"
rm -f "$QEMU_END"
touch "$QEMU_LOG"
_trap() {
func="$1" ; shift
@@ -87,17 +90,18 @@ terminal() {
_graceful_shutdown() {
local cnt=0
local code=$?
local pid cnt response
local pid url response
set +e
if [ -f "$QEMU_COUNT" ]; then
echo && info "Ignored $1 signal, already shutting down..."
if [ -f "$QEMU_END" ]; then
echo && info "Received $1 signal while already shutting down..."
return
fi
echo 0 > "$QEMU_COUNT"
touch "$QEMU_END"
echo && info "Received $1 signal, sending shutdown command..."
if [ ! -f "$QEMU_PID" ]; then
@@ -132,15 +136,12 @@ _graceful_shutdown() {
fi
while [ "$(cat $QEMU_COUNT)" -lt "$QEMU_TIMEOUT" ]; do
while [ "$cnt" -lt "$QEMU_TIMEOUT" ]; do
! isAlive "$pid" && break
sleep 1
# Increase the counter
cnt=$(($(cat $QEMU_COUNT)+1))
echo $cnt > "$QEMU_COUNT"
cnt=$((cnt+1))
[[ "$DEBUG" == [Yy1]* ]] && info "Shutting down, waiting... ($cnt/$QEMU_TIMEOUT)"
@@ -149,14 +150,16 @@ _graceful_shutdown() {
done
if [ "$(cat $QEMU_COUNT)" -ge "$QEMU_TIMEOUT" ]; then
echo && error "Shutdown timeout reached!"
if [ "$cnt" -ge "$QEMU_TIMEOUT" ]; then
echo && error "Shutdown timeout reached, aborting..."
fi
finish "$code" && return "$code"
}
_trap _graceful_shutdown SIGTERM SIGHUP SIGINT SIGABRT SIGQUIT
if [[ "$CONSOLE" != [Yy]* ]]; then
_trap _graceful_shutdown SIGTERM SIGHUP SIGINT SIGABRT SIGQUIT
fi
MON_OPTS="\
-pidfile $QEMU_PID \