bep40 commited on
Commit
bb8e137
·
verified ·
1 Parent(s): 7fdeafc

Restore to commit 60e310a - auto restore on startup

Browse files
Files changed (1) hide show
  1. _run.py +8 -9
_run.py CHANGED
@@ -3,18 +3,17 @@ import os, sys
3
  # Auto-restore from commit 60e310a if needed
4
  _restore_marker = '/app/.restored_60e310a'
5
  if not os.path.exists(_restore_marker):
 
6
  try:
7
  import subprocess
8
- # Check if we're on the right commit
9
- result = subprocess.run(['git', 'log', '--oneline', '-1'], capture_output=True, text=True, cwd='/app')
10
- current_commit = result.stdout.strip()
11
- if '60e310a' not in current_commit:
12
- # Force reset to 60e310a
13
- subprocess.run(['git', 'fetch', 'origin', '60e310a'], cwd='/app', capture_output=True)
14
- subprocess.run(['git', 'reset', '--hard', '60e310a'], cwd='/app', capture_output=True)
15
- # Mark as restored
16
- open(_restore_marker, 'w').write('restored')
17
  except Exception as e:
18
  print(f"[RESTORE] Error: {e}", flush=True)
 
 
19
 
20
  from app_v2_entry import app # v5-stable inline bongda proxy
 
3
  # Auto-restore from commit 60e310a if needed
4
  _restore_marker = '/app/.restored_60e310a'
5
  if not os.path.exists(_restore_marker):
6
+ print("[RESTORE] First run - restoring from commit 60e310a...", flush=True)
7
  try:
8
  import subprocess
9
+ result = subprocess.run([sys.executable, '/app/restore.py'], capture_output=True, text=True, timeout=120)
10
+ print(f"[RESTORE] stdout: {result.stdout[-500:]}", flush=True)
11
+ print(f"[RESTORE] stderr: {result.stderr[-500:]}", flush=True)
12
+ if result.returncode != 0:
13
+ print(f"[RESTORE] Failed with code {result.returncode}", flush=True)
 
 
 
 
14
  except Exception as e:
15
  print(f"[RESTORE] Error: {e}", flush=True)
16
+ # Mark as restored even if failed (avoid retry loop)
17
+ open(_restore_marker, 'w').write('restored')
18
 
19
  from app_v2_entry import app # v5-stable inline bongda proxy