Formatting

This commit is contained in:
2026-02-27 20:38:04 -06:00
parent e7d29c77b0
commit e6f55965d8
3 changed files with 121 additions and 118 deletions

View File

@@ -72,12 +72,14 @@ fi
log "INFO" "Waiting for sync confirmation on $RESPONSE_TOPIC..."
# Start a subshell that kills the subscriber after 10 seconds if no message arrives
( sleep 10; mosquitto_pub -h 127.0.0.1 -t "$RESPONSE_TOPIC" -m "SaveSync=timeout" ) &
(
sleep 10
mosquitto_pub -h 127.0.0.1 -t "$RESPONSE_TOPIC" -m "SaveSync=timeout"
) &
TIMEOUT_PID=$!
# -C 1 ensures we exit after receiving either the real response or the timeout message
mosquitto_sub -h 127.0.0.1 -p 1883 -t "$RESPONSE_TOPIC" -C 1 | while IFS="=" read -r key value
do
mosquitto_sub -h 127.0.0.1 -p 1883 -t "$RESPONSE_TOPIC" -C 1 | while IFS="=" read -r key value; do
# Kill the background sleep timer since we got a message
kill "$TIMEOUT_PID" 2>/dev/null
@@ -93,4 +95,3 @@ do
;;
esac
done

View File

@@ -11,8 +11,7 @@ log_to_file() {
}
# Subscribe and wait for log entries
mosquitto_sub -h 127.0.0.1 -t "$LOG_TOPIC" | while read -r line
do
mosquitto_sub -h 127.0.0.1 -t "$LOG_TOPIC" | while read -r line; do
# The line will look like: SaveLog=[2026-...] [INFO] ...
# We strip the "SaveLog=" prefix
msg_content="${line#SaveLog=}"

View File

@@ -25,8 +25,7 @@ sleep 2
log "INFO" "--- ES Event Daemon Started ---"
# --- Main Listener Loop ---
mosquitto_sub -h 127.0.0.1 -p 1883 -q 0 -t "$TOPIC" | while IFS="=" read -r key value
do
mosquitto_sub -h 127.0.0.1 -p 1883 -q 0 -t "$TOPIC" | while IFS="=" read -r key value; do
# 1. Clean input
value=$(echo "$value" | tr -d '\r')
@@ -80,7 +79,11 @@ do
fi
# Reset variables immediately so the loop is ready for the next line
this_system_id=""; this_game_path=""; this_save_path=""; this_action=""; this_backup_path=""
this_system_id=""
this_game_path=""
this_save_path=""
this_action=""
this_backup_path=""
;;
esac
done