From 58414331f8ef819b1aab59f3724581f1603acc69 Mon Sep 17 00:00:00 2001 From: aerom Date: Tue, 5 May 2026 02:24:59 -0400 Subject: [PATCH] Add background launcher scripts (Iniciar.vbs, Detener.bat, Ver_Log.bat) --- Detener.bat | 11 ++++++++++ Iniciar.vbs | 34 +++++++++++++++++++++++++++++++ Iniciar_Ambos.vbs | 51 +++++++++++++++++++++++++++++++++++++++++++++++ Ver_Log.bat | 7 +++++++ logs/.gitkeep | 1 + 5 files changed, 104 insertions(+) create mode 100644 Detener.bat create mode 100644 Iniciar.vbs create mode 100644 Iniciar_Ambos.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..49cdf21 --- /dev/null +++ b/Detener.bat @@ -0,0 +1,11 @@ +@echo off +title Detener MarineInvoice +echo Deteniendo MarineInvoice (puerto 5000)... + +for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":5000 " ^| 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..dcb0c4e --- /dev/null +++ b/Iniciar.vbs @@ -0,0 +1,34 @@ +' MarineInvoice — Inicia servidor en segundo plano (sin ventana) +Option Explicit +Dim oShell, sDir, sPython, sLog + +sDir = "C:\MarineInvoice" +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 5000 +Dim oExec, sOut +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5000 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) > 0 Then + MsgBox "MarineInvoice ya está corriendo en el puerto 5000.", 64, "MarineInvoice" + 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 :5000 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) > 0 Then + MsgBox "MarineInvoice iniciado correctamente." & vbCrLf & vbCrLf & _ + "URL: http://localhost:5000" & vbCrLf & _ + "Tailscale: http://100.96.43.86:5000", 64, "MarineInvoice" +Else + MsgBox "El servidor tardó en iniciar. Revisa logs\server.log si hay errores.", 48, "MarineInvoice" +End If diff --git a/Iniciar_Ambos.vbs b/Iniciar_Ambos.vbs new file mode 100644 index 0000000..4074e47 --- /dev/null +++ b/Iniciar_Ambos.vbs @@ -0,0 +1,51 @@ +' Inicia MarineInvoice y MarineMaintenance en segundo plano +Option Explicit +Dim oShell +Dim sPython +Dim sLog1, sLog2 + +sPython = "C:\Users\aerom\AppData\Local\Python\pythoncore-3.14-64\pythonw.exe" +sLog1 = "C:\MarineInvoice\logs\server.log" +sLog2 = "C:\MarineMaintenance\logs\server.log" + +Set oShell = CreateObject("WScript.Shell") + +' ── MarineInvoice (5000) ────────────────────────────────────────────────────── +Dim oExec, sOut +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5000 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) = 0 Then + oShell.Run "cmd /c cd /d ""C:\MarineInvoice"" && """ & sPython & """ app.py >> """ & sLog1 & """ 2>&1", 0, False +End If + +' ── MarineMaintenance (5500) ───────────────────────────────────────────────── +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5500 | findstr LISTENING") +sOut = oExec.StdOut.ReadAll() +If Len(Trim(sOut)) = 0 Then + oShell.Run "cmd /c cd /d ""C:\MarineMaintenance"" && """ & sPython & """ app.py >> """ & sLog2 & """ 2>&1", 0, False +End If + +WScript.Sleep 2000 + +' ── Verificar ambos ────────────────────────────────────────────────────────── +Dim ok1, ok2 +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5000 | findstr LISTENING") +ok1 = Len(Trim(oExec.StdOut.ReadAll())) > 0 + +Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5500 | findstr LISTENING") +ok2 = Len(Trim(oExec.StdOut.ReadAll())) > 0 + +Dim sMsg +sMsg = "Estado de servidores:" & vbCrLf & vbCrLf +If ok1 Then + sMsg = sMsg & "OK MarineInvoice -> http://localhost:5000" & vbCrLf +Else + sMsg = sMsg & "ERR MarineInvoice -> no respondio (ver logs)" & vbCrLf +End If +If ok2 Then + sMsg = sMsg & "OK MarineMaintenance -> http://localhost:5500" & vbCrLf +Else + sMsg = sMsg & "ERR MarineMaintenance -> no respondio (ver logs)" & vbCrLf +End If + +MsgBox sMsg, 64, "Servidores Marinos" 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 @@ +