Simplify: remove auto-update, run.ps1 just starts the server
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
Set-Location $root
|
||||
|
||||
# Verificar Python
|
||||
$python = (Get-Command python -ErrorAction SilentlyContinue)
|
||||
if (-not $python) {
|
||||
Write-Host "Descargando Python 3.12..."
|
||||
$url = "https://www.python.org/ftp/python/3.12.9/python-3.12.9-amd64.exe"
|
||||
$dest = "$env:TEMP\python-installer.exe"
|
||||
Invoke-WebRequest -Uri $url -OutFile $dest
|
||||
Write-Host "Instalando Python..."
|
||||
Start-Process -Wait -FilePath $dest -ArgumentList "/quiet InstallAllUsers=0 PrependPath=1 Include_test=0"
|
||||
Write-Host "Python instalado. Cerra y abri PowerShell de nuevo."
|
||||
Read-Host "Presiona Enter para salir"
|
||||
exit
|
||||
}
|
||||
|
||||
# Pull
|
||||
Write-Host "Pull inicial..."
|
||||
git pull
|
||||
python -m pip install -q -r requirements.txt
|
||||
|
||||
Write-Host "`n=========================================="
|
||||
Write-Host " Servidor: http://localhost:8080"
|
||||
Write-Host " Auto-update cada 60 segundos"
|
||||
Write-Host " Cerra esta ventana para detener"
|
||||
Write-Host "==========================================`n"
|
||||
|
||||
python auto_update.py
|
||||
@@ -1,23 +0,0 @@
|
||||
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}")␍
|
||||
␍
|
||||
if __name__ == '__main__':␍
|
||||
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)␍
|
||||
@@ -6,18 +6,17 @@ if (-not $python) {
|
||||
Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.12.9/python-3.12.9-amd64.exe" -OutFile "$env:TEMP\python-installer.exe"
|
||||
Write-Host "Instalando Python..."
|
||||
Start-Process -Wait -FilePath "$env:TEMP\python-installer.exe" -ArgumentList "/quiet InstallAllUsers=0 PrependPath=1 Include_test=0"
|
||||
Write-Host "Python instalado. Cerrá y abrí PowerShell de nuevo, o ejecutá este script otra vez."
|
||||
Write-Host "Python instalado. Cerra y abri PowerShell de nuevo."
|
||||
Read-Host "Enter para salir"
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Host "Pull inicial..."
|
||||
git pull
|
||||
Write-Host "Instalando dependencias..."
|
||||
python -m pip install -q -r requirements.txt
|
||||
|
||||
Write-Host "`n=========================================="
|
||||
Write-Host " Servidor: http://localhost:8080"
|
||||
Write-Host " Auto-update cada 60 segundos"
|
||||
Write-Host "=========================================="
|
||||
Write-Host " Presiona Ctrl+C para detener"
|
||||
Write-Host "==========================================`n"
|
||||
|
||||
python auto_update.py
|
||||
python main.py
|
||||
|
||||
Reference in New Issue
Block a user