Spaces:
Building
Building
fix: sync state on natural gateway exit to preserve user-set keys
Browse filesWhen 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>
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
|