Badal commited on
Commit
fbe2468
·
1 Parent(s): c477021

Simple working sync with quiet mode + delay

Browse files
Files changed (1) hide show
  1. entrypoint.sh +10 -9
entrypoint.sh CHANGED
@@ -3,21 +3,26 @@
3
  # Ensure HF CLI is in PATH
4
  export PATH="$HOME/.local/bin:$PATH"
5
 
 
6
  # Set HF Token from Space Secrets
7
  export HF_TOKEN="${HF_TOKEN}"
8
 
 
9
  # Variables
10
  BUCKET='hf://buckets/bk939448/opencodeai'
11
  SOURCE='/data'
12
 
 
13
  # Configure Git
14
  git config --global user.email 'badal@example.com'
15
  git config --global user.name 'Badal'
16
 
 
17
  # Set OpenCode path
18
  OP_PATH=$(find / -name opencode -type f -printf '%h' -quit 2>/dev/null)
19
  export PATH="$OP_PATH:$PATH"
20
 
 
21
  # ============================================
22
  # STEP 1: RESTORE (Try, but continue if bucket empty)
23
  # ============================================
@@ -28,6 +33,7 @@ else
28
  echo '=== [STEP 1] Restore skipped (bucket empty or failed - continuing anyway) ==='
29
  fi
30
 
 
31
  # ============================================
32
  # STEP 2: START OPENCODE
33
  # ============================================
@@ -38,8 +44,9 @@ opencode web --port 7860 --hostname 0.0.0.0 > /tmp/opencode.log 2>&1 &
38
  sleep 10
39
  echo '=== [STEP 2] OPENCODE STARTED ==='
40
 
 
41
  # ============================================
42
- # STEP 3: REAL-TIME CONTINUOUS SYNC (with timeout + error handling)
43
  # ============================================
44
  echo '=== [STEP 3] STARTING REAL-TIME SYNC ==='
45
  while true; do
@@ -49,13 +56,7 @@ while true; do
49
  exit 1
50
  fi
51
 
52
- # Sync with 30 sec timeout to prevent hanging
53
- timeout 30 hf sync "$SOURCE" "$BUCKET" --delete --quiet
54
-
55
- # If sync fails or times out, log it but continue
56
- if [ $? -ne 0 ]; then
57
- echo "WARNING: Sync issue at $(date) - continuing..."
58
- fi
59
-
60
  sleep 2
61
  done
 
3
  # Ensure HF CLI is in PATH
4
  export PATH="$HOME/.local/bin:$PATH"
5
 
6
+
7
  # Set HF Token from Space Secrets
8
  export HF_TOKEN="${HF_TOKEN}"
9
 
10
+
11
  # Variables
12
  BUCKET='hf://buckets/bk939448/opencodeai'
13
  SOURCE='/data'
14
 
15
+
16
  # Configure Git
17
  git config --global user.email 'badal@example.com'
18
  git config --global user.name 'Badal'
19
 
20
+
21
  # Set OpenCode path
22
  OP_PATH=$(find / -name opencode -type f -printf '%h' -quit 2>/dev/null)
23
  export PATH="$OP_PATH:$PATH"
24
 
25
+
26
  # ============================================
27
  # STEP 1: RESTORE (Try, but continue if bucket empty)
28
  # ============================================
 
33
  echo '=== [STEP 1] Restore skipped (bucket empty or failed - continuing anyway) ==='
34
  fi
35
 
36
+
37
  # ============================================
38
  # STEP 2: START OPENCODE
39
  # ============================================
 
44
  sleep 10
45
  echo '=== [STEP 2] OPENCODE STARTED ==='
46
 
47
+
48
  # ============================================
49
+ # STEP 3: REAL-TIME CONTINUOUS SYNC
50
  # ============================================
51
  echo '=== [STEP 3] STARTING REAL-TIME SYNC ==='
52
  while true; do
 
56
  exit 1
57
  fi
58
 
59
+ # Real-time continuous sync (quiet mode)
60
+ hf sync "$SOURCE" "$BUCKET" --delete --quiet
 
 
 
 
 
 
61
  sleep 2
62
  done