Files
keyhunter-parser/WATCHDOG.bat

45 lines
1.4 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
title KeyHunter WATCHDOG
color 0C
cd /d "C:\Users\User\Desktop\keyhunter"
echo ============================================================
echo KeyHunter WATCHDOG
echo Checks every 60s. Restarts parser+validator if dead.
echo ============================================================
echo.
:LOOP
set PARSER_ALIVE=0
set VALIDATOR_ALIVE=0
REM Check parser: any python.exe with eternal_v10.py in command line?
for /f "tokens=2 delims=," %%a in ('"wmic process where \"name='python.exe'\" get processid,commandline /format:csv 2>nul | findstr eternal_v10"') do (
set PARSER_ALIVE=1
)
REM Check validator
for /f "tokens=2 delims=," %%a in ('"wmic process where \"name='python.exe'\" get processid,commandline /format:csv 2>nul | findstr validator_v10"') do (
set VALIDATOR_ALIVE=1
)
echo [%TIME%] Parser=!PARSER_ALIVE! Validator=!VALIDATOR_ALIVE!
if "!PARSER_ALIVE!"=="0" (
echo [%TIME%] *** PARSER DEAD — starting ***
del /Q data\parser.pid 2>nul
start "KeyHunter PARSER v10" /MIN cmd /C "color 0A & python -u src\eternal_v10.py"
timeout /t 5 /nobreak >nul
)
if "!VALIDATOR_ALIVE!"=="0" (
echo [%TIME%] *** VALIDATOR DEAD — starting ***
del /Q data\validator.pid 2>nul
timeout /t 2 /nobreak >nul
start "KeyHunter VALIDATOR v10" /MIN cmd /C "color 0E & python -u src\validator_v10.py"
timeout /t 5 /nobreak >nul
)
timeout /t 60 /nobreak >nul
goto LOOP