somratpro Claude Sonnet 4.6 commited on
Commit
bdb63d2
·
1 Parent(s): 6c85d60

fix: sync state on natural gateway exit to preserve user-set keys

Browse files

When user restarts the gateway from Hermes dashboard, the gateway
process exits naturally. wait() returns but SIGTERM trap never fires,
so no sync runs before the container shuts down. Keys set via the UI
are lost because the next restore pulls a stale backup.

Add an explicit sync-once after wait() to cover the natural-exit path.
SIGTERM path already handled by graceful_shutdown trap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. start.sh +7 -0
start.sh CHANGED
@@ -372,3 +372,10 @@ if [ -n "${HF_TOKEN:-}" ]; then
372
  fi
373
 
374
  wait "$GATEWAY_PID"
 
 
 
 
 
 
 
 
372
  fi
373
 
374
  wait "$GATEWAY_PID"
375
+
376
+ # Gateway exited (e.g. user restarted from Hermes UI). Sync before container dies.
377
+ # SIGTERM path is handled by graceful_shutdown trap above; this covers natural exit.
378
+ if [ -n "${HF_TOKEN:-}" ]; then
379
+ echo "Gateway exited — syncing state before shutdown..."
380
+ python3 "$APP_DIR/hermes-sync.py" sync-once || echo "Warning: final sync failed."
381
+ fi