inport fix
CI / check (push) Failing after 13s
CI / release (push) Skipped
CI / deploy (push) Skipped

This commit is contained in:
openhands committed 2026-08-08 21:39:52 +02:00
1 parent 6a67fb6e83
commit ebd2ff131c
5 files changed
+387 -411

No files matched your search

+83 -18
View File
@@ -1323,24 +1323,81 @@ do_permissions() {
fix_perms
}
# Wait for the emulator service to be active and its game port to be listening.
wait_for_emulator_health() {
local hc=0
while [ "$hc" -lt "$HEALTH_RETRIES" ]; do
if service_active "$EMULATOR_SERVICE" && emulator_port_open; then
ok "Emulator health check passed (service up + port listening)"
return 0
fi
hc=$((hc+1))
[ "$hc" -lt "$HEALTH_RETRIES" ] && sleep "$HEALTH_INTERVAL"
done
return 1
}
# Resolve the newest built emulator jar filename inside the target directory.
emulator_jar_name() {
find "$EMULATOR_MODULE/target" -maxdepth 1 -name 'Polaris-*-jar-with-dependencies.jar' \
-printf '%T@ %p\n' 2>/dev/null | sort -rn | sed -n '1s/^[0-9.]* //p' | xargs -r basename 2>/dev/null
}
# Run the emulator's built-in Flyway repair against the database. This realigns
# flyway_schema_history with the packaged migrations (e.g. clearing "applied
# migration not resolved locally" drift) without touching hotel data.
flyaway_repair_db() {
local jar; jar=$(emulator_jar_name)
if [ -z "$jar" ]; then
fail "No emulator jar found in %s" "$EMULATOR_MODULE/target"
return 1
fi
command -v java >/dev/null 2>&1 || { fail "Missing: java"; return 1; }
cd "$EMULATOR_MODULE/target"
spinner_start "Running Flyway repair..."
if timeout 300 java -Dfile.encoding=UTF8 -jar "$jar" --migrations=repair >> "$LOG_FILE" 2>&1; then
spinner_stop ok
ok "Flyway schema history repaired (see: %s)" "$LOG_FILE"
cd "$SCRIPT_DIR"
return 0
fi
spinner_stop fail
tail -30 "$LOG_FILE" | grep -iE 'repair|migrat|error|exception' || true
cd "$SCRIPT_DIR"
return 1
}
do_restart() {
step 8 8 "Restart Services"
if systemctl cat "$EMULATOR_SERVICE" &>/dev/null; then
sudo systemctl restart "$EMULATOR_SERVICE" 2>/dev/null && ok "$EMULATOR_SERVICE restarted" || warn "Restart failed"
local hc=0
while [ "$hc" -lt "$HEALTH_RETRIES" ]; do
if service_active "$EMULATOR_SERVICE" && emulator_port_open; then
ok "Emulator health check passed (service up + port listening)"
break
fi
hc=$((hc+1))
[ "$hc" -lt "$HEALTH_RETRIES" ] && sleep "$HEALTH_INTERVAL"
done
if [ "$hc" -eq "$HEALTH_RETRIES" ]; then
if ! wait_for_emulator_health; then
warn "Emulator not healthy after %s retries" "$HEALTH_RETRIES"
sudo journalctl -u "$EMULATOR_SERVICE" --no-pager -n 20 2>/dev/null || true
ERRORS=$((ERRORS + 1))
ROLLBACK_NEEDED=true
# Flyway schema drift (an applied migration no longer resolvable
# locally) aborts startup. Repair the history table and retry once
# before giving up, so updates survive upstream migration renames.
local flyway_drift=false
if sudo journalctl -u "$EMULATOR_SERVICE" --no-pager -n 300 2>/dev/null \
| grep -qiE 'applied migration not resolved locally|FlywayValidateException|Migrations have failed validation'; then
flyway_drift=true
warn "Flyway schema drift detected — running repair and retrying"
# Halt the restart loop so repair cannot race migrate on the history table
sudo systemctl stop "$EMULATOR_SERVICE" 2>/dev/null || true
if flyaway_repair_db; then
sudo systemctl start "$EMULATOR_SERVICE" 2>/dev/null || true
if wait_for_emulator_health; then
ok "Emulator healthy after Flyway repair"
flyway_drift=false
fi
else
sudo systemctl start "$EMULATOR_SERVICE" 2>/dev/null || true
fi
fi
if [ "$flyway_drift" = true ]; then
ERRORS=$((ERRORS + 1))
ROLLBACK_NEEDED=true
fi
fi
elif command -v pm2 &>/dev/null; then
pm2 restart all 2>/dev/null && ok "PM2 restarted" || warn "PM2 restart failed"
@@ -1648,10 +1705,10 @@ cmd_flyaway_repair() {
return
fi
step 1 6 "System Diagnostics"
step 1 7 "System Diagnostics"
preflight_check
step 2 6 "$(_t "Flyaway Repair")"
step 2 7 "$(_t "Flyaway Repair")"
local repaired=0
for repo in "$EMULATOR_REPO" "$NITRO_CLIENT" "$NITRO_RENDERER"; do
@@ -1691,18 +1748,26 @@ cmd_flyaway_repair() {
repaired=$((repaired + 1))
done
# Realign Flyway schema history with the packaged migrations
step 3 7 "$(_t "Flyway DB Repair")"
if flyaway_repair_db; then
ok "$(_t "Flyway schema history repaired")"
else
fail "$(_t "Flyway DB repair failed — the emulator will retry on restart")"
fi
# Fix permissions
step 3 6 "$(_t "Set Permissions")"
step 4 7 "$(_t "Set Permissions")"
fix_perms
ok "Permissions fixed"
# Sync / validate configs
step 4 6 "$(_t "Sync Configurations")"
step 5 7 "$(_t "Sync Configurations")"
sync_configs
# Rebuild frontend if dist is missing or empty
if [ ! -d "$NITRO_CLIENT/dist" ] || [ -z "$(ls -A "$NITRO_CLIENT/dist" 2>/dev/null)" ]; then
step 5 6 "$(_t "Rebuild Frontend")"
step 6 7 "$(_t "Rebuild Frontend")"
spinner_start "$(_t "Building frontend...")"
cd "$NITRO_CLIENT"
if yarn build >> "$LOG_FILE" 2>&1; then
@@ -1719,7 +1784,7 @@ cmd_flyaway_repair() {
# Rebuild emulator if jar is missing
if [ ! -d "$EMULATOR_MODULE/target" ] || ! ls "$EMULATOR_MODULE"/target/Polaris-*-jar-with-dependencies.jar &>/dev/null 2>&1; then
step 6 6 "$(_t "Rebuild Emulator")"
step 7 7 "$(_t "Rebuild Emulator")"
cd "$EMULATOR_MODULE"
backup_binaries
ROLLBACK_NEEDED=true