From b57fa85a97c9e1e6904e71b76d21611c4f327d0b Mon Sep 17 00:00:00 2001 From: aerom Date: Tue, 5 May 2026 02:25:07 -0400 Subject: [PATCH] Add background launcher scripts (Iniciar.vbs, Detener.bat, Ver_Log.bat) --- Detener.bat | 11 +++++++++++ Iniciar.vbs | 34 ++++++++++++++++++++++++++++++++++ Ver_Log.bat | 7 +++++++ logs/.gitkeep | 1 + 4 files changed, 53 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..b2dcff7 --- /dev/null +++ b/Detener.bat @@ -0,0 +1,11 @@ +@echo off +title Detener MarineMaintenance +echo Deteniendo MarineMaintenance (puerto 5500)... + +for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":5500 " ^| 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..4dc6a19 --- /dev/null +++ b/Iniciar.vbs @@ -0,0 +1,34 @@ +' MarineMaintenance — Inicia servidor en segundo plano (sin ventana) +Option Explicit +Dim oShell, sDir, sPython, sLog + +sDir = "C:\MarineMaintenance" +sPython = "C:\Users\aerom\AppData\Local\Python\pythoncore-3.14-64\pythonw.exe" +sLog = sDir & "\logs\server.log" + +Set oShell = CreateObject("WScript.Shell") + +' Verificar si ya está corriendo en puerto 5500 +Dim oExec, sOut +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5500 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) > 0 Then + MsgBox "MarineMaintenance ya está corriendo en el puerto 5500.", 64, "MarineMaintenance" + WScript.Quit +End If + +' Iniciar servidor oculto — redirige salida al log +oShell.Run "cmd /c cd /d """ & sDir & """ && """ & sPython & """ app.py >> """ & sLog & """ 2>&1", 0, False + +WScript.Sleep 1500 + +' Confirmar que arrancó +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5500 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) > 0 Then + MsgBox "MarineMaintenance iniciado correctamente." & vbCrLf & vbCrLf & _ + "URL: http://localhost:5500" & vbCrLf & _ + "Tailscale: http://100.96.43.86:5500", 64, "MarineMaintenance" +Else + MsgBox "El servidor tardó en iniciar. Revisa logs\server.log si hay errores.", 48, "MarineMaintenance" +End If diff --git a/Ver_Log.bat b/Ver_Log.bat new file mode 100644 index 0000000..99ad707 --- /dev/null +++ b/Ver_Log.bat @@ -0,0 +1,7 @@ +@echo off +if exist "logs\server.log" ( + notepad "logs\server.log" +) else ( + echo No hay log todavia. Inicia el servidor primero. + pause +) diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/logs/.gitkeep @@ -0,0 +1 @@ +