Fix: use auto_update.py instead of inline Python in batch
This commit is contained in:
+3
-24
@@ -13,15 +13,12 @@ if not exist python\python.exe (
|
|||||||
python\python.exe -c "import urllib.request; exec(urllib.request.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"
|
python\python.exe -c "import urllib.request; exec(urllib.request.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"
|
||||||
)
|
)
|
||||||
|
|
||||||
:: ---- 2. Instalar watchdog para auto-pull ----
|
:: ---- 2. Pull inicial ----
|
||||||
python\python.exe -m pip install -q watchdog 2>nul
|
|
||||||
|
|
||||||
:: ---- 3. Pull inicial ----
|
|
||||||
echo [%date% %time%] Pull inicial...
|
echo [%date% %time%] Pull inicial...
|
||||||
git pull
|
git pull
|
||||||
python\python.exe -m pip install -q -r requirements.txt 2>nul
|
python\python.exe -m pip install -q -r requirements.txt 2>nul
|
||||||
|
|
||||||
:: ---- 4. Arrancar con auto-pull cada 60s ----
|
:: ---- 3. Arrancar con auto-pull cada 60s ----
|
||||||
echo.
|
echo.
|
||||||
echo ==========================================
|
echo ==========================================
|
||||||
echo Servidor: http://localhost:8080
|
echo Servidor: http://localhost:8080
|
||||||
@@ -29,22 +26,4 @@ echo Auto-update cada 60 segundos
|
|||||||
echo Cerra esta ventana para detener
|
echo Cerra esta ventana para detener
|
||||||
echo ==========================================
|
echo ==========================================
|
||||||
|
|
||||||
python\python.exe -c "
|
python\python.exe auto_update.py
|
||||||
import uvicorn, sys, subprocess, threading, time
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
root = Path(__file__).parent.resolve()
|
|
||||||
sys.path.insert(0, str(root))
|
|
||||||
|
|
||||||
def auto_puller():
|
|
||||||
while True:
|
|
||||||
time.sleep(60)
|
|
||||||
try:
|
|
||||||
subprocess.run(['git', 'pull'], cwd=root, capture_output=True, text=True, timeout=30)
|
|
||||||
subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'], cwd=root, capture_output=True, timeout=30)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
threading.Thread(target=auto_puller, daemon=True).start()
|
|
||||||
uvicorn.run('main:app', host='0.0.0.0', port=8080, reload=True)
|
|
||||||
"
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import subprocess, threading, time, sys, os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
root = Path(__file__).parent.resolve()
|
||||||
|
|
||||||
|
def pull_loop():
|
||||||
|
while True:
|
||||||
|
time.sleep(60)
|
||||||
|
try:
|
||||||
|
r = subprocess.run(['git', 'pull'], cwd=root, capture_output=True, text=True, timeout=30)
|
||||||
|
if r.stdout.strip():
|
||||||
|
print(f"[auto] git pull: {r.stdout.strip()}")
|
||||||
|
subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'],
|
||||||
|
cwd=root, capture_output=True, timeout=30)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[auto] pull error: {e}")
|
||||||
|
|
||||||
|
threading.Thread(target=pull_loop, daemon=True).start()
|
||||||
|
os.chdir(root)
|
||||||
|
sys.path.insert(0, str(root))
|
||||||
|
|
||||||
|
import uvicorn, main
|
||||||
|
uvicorn.run('main:app', host='0.0.0.0', port=8080, reload=True)
|
||||||
Reference in New Issue
Block a user