Add background launcher scripts (Iniciar.vbs, Detener.bat, Ver_Log.bat)

This commit is contained in:
2026-05-05 02:24:59 -04:00
parent 764b72a318
commit 58414331f8
5 changed files with 104 additions and 0 deletions
+11
View File
@@ -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
+34
View File
@@ -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
+51
View File
@@ -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"
+7
View File
@@ -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
)
+1
View File
@@ -0,0 +1 @@