Anurag commited on
Commit
8b566d2
·
unverified ·
1 Parent(s): 73b8a17

Fix shutdown process to handle sync loop correctly

Browse files

Fixed bug by ensuring the background sync loop is killed before running the shutdown syncs to avoid timeout issues.

Files changed (1) hide show
  1. start.sh +11 -0
start.sh CHANGED
@@ -925,6 +925,17 @@ graceful_shutdown() {
925
  echo "Shutting down..."
926
  if [ -f "/home/node/app/openclaw-sync.py" ] && [ -n "${HF_TOKEN:-}" ]; then
927
  echo "Saving state before exit..."
 
 
 
 
 
 
 
 
 
 
 
928
  timeout 8s python3 /home/node/app/openclaw-sync.py sync-once-settled || \
929
  echo "Warning: could not complete settled shutdown sync"
930
  sleep 1
 
925
  echo "Shutting down..."
926
  if [ -f "/home/node/app/openclaw-sync.py" ] && [ -n "${HF_TOKEN:-}" ]; then
927
  echo "Saving state before exit..."
928
+ # BUG FIX: kill the background sync loop *before* running the shutdown
929
+ # syncs. The loop holds the sync lock while uploading; if it is
930
+ # mid-upload when sync-once-settled runs, the 8-second timeout fires
931
+ # before the lock is released and the settled-sync is silently skipped.
932
+ # Killing the loop first releases the lock immediately (fcntl.flock is
933
+ # released on process exit) so sync-once-settled can acquire it cleanly.
934
+ if [ -n "${SYNC_LOOP_PID:-}" ]; then
935
+ kill "$SYNC_LOOP_PID" 2>/dev/null || true
936
+ # Give Python a moment to flush and release the lock file.
937
+ sleep 0.5
938
+ fi
939
  timeout 8s python3 /home/node/app/openclaw-sync.py sync-once-settled || \
940
  echo "Warning: could not complete settled shutdown sync"
941
  sleep 1