Spaces:
Running
Running
Anurag commited on
Fix shutdown process to handle sync loop correctly
Browse filesFixed bug by ensuring the background sync loop is killed before running the shutdown syncs to avoid timeout issues.
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
|