From 597f931c5b79b63b9c02da1a42b51cc9018e855e Mon Sep 17 00:00:00 2001 From: aerom Date: Tue, 5 May 2026 02:34:49 -0400 Subject: [PATCH] Add background launcher scripts --- Detener.bat | 9 +++++++++ Iniciar.vbs | 32 ++++++++++++++++++++++++++++++++ Ver_Log.bat | 2 ++ logs/.gitkeep | 0 4 files changed, 43 insertions(+) create mode 100644 Detener.bat create mode 100644 Iniciar.vbs create mode 100644 Ver_Log.bat create mode 100644 logs/.gitkeep diff --git a/Detener.bat b/Detener.bat new file mode 100644 index 0000000..bb771db --- /dev/null +++ b/Detener.bat @@ -0,0 +1,9 @@ +@echo off +title Detener AidsMonitoring +echo Deteniendo AidsMonitoring (puerto 5503)... +for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":5503 " ^| findstr "LISTENING"') do ( + echo Terminando proceso PID %%a... + taskkill /F /PID %%a >nul 2>&1 +) +echo Listo. +timeout /t 2 >nul diff --git a/Iniciar.vbs b/Iniciar.vbs new file mode 100644 index 0000000..9abd960 --- /dev/null +++ b/Iniciar.vbs @@ -0,0 +1,32 @@ +' AidsMonitoring — Inicia servidor uvicorn en segundo plano (sin ventana) +Option Explicit +Dim oShell, sBackend, sPython, sLog + +sBackend = "C:\AidsMonitoring\backend" +sPython = "C:\Users\aerom\AppData\Local\Python\pythoncore-3.14-64\pythonw.exe" +sLog = "C:\AidsMonitoring\logs\server.log" + +Set oShell = CreateObject("WScript.Shell") + +Dim oExec, sOut +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5503 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) > 0 Then + MsgBox "AidsMonitoring ya esta corriendo en el puerto 5503.", 64, "AidsMonitoring" + WScript.Quit +End If + +' Uvicorn via pythonw — redirige stdout/stderr al log +oShell.Run "cmd /c cd /d """ & sBackend & """ && """ & sPython & """ -m uvicorn main:app --host 0.0.0.0 --port 5503 >> """ & sLog & """ 2>&1", 0, False + +WScript.Sleep 2500 + +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5503 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) > 0 Then + MsgBox "AidsMonitoring iniciado correctamente." & vbCrLf & vbCrLf & _ + "URL: http://localhost:5503" & vbCrLf & _ + "Tailscale: http://100.96.43.86:5503", 64, "AidsMonitoring" +Else + MsgBox "El servidor tardo en iniciar. Revisa logs\server.log si hay errores.", 48, "AidsMonitoring" +End If diff --git a/Ver_Log.bat b/Ver_Log.bat new file mode 100644 index 0000000..be84a0e --- /dev/null +++ b/Ver_Log.bat @@ -0,0 +1,2 @@ +@echo off +if exist "logs\server.log" (notepad "logs\server.log") else (echo No hay log todavia. & pause) diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 0000000..e69de29