Spaces:
Running
Running
Restore to commit 60e310a - auto restore on startup
Browse files
_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 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
if
|
| 12 |
-
|
| 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
|