| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 | @echo offREM snail-job.bat start|stop|restart|statusset AppName=snail-job-server-exec.jarREM JVM optionsset JVM_OPTS=-Dname=%AppName% -Duser.timezone=Asia/Shanghai -XX:+HeapDumpOnOutOfMemoryError -XX:+UseZGCset APP_HOME=%cd%REM Check if an action is passed, default to "start" if emptyif "%1"=="" (    echo No action provided, default to: start    set ACTION=start) else (    set ACTION=%1)if "%AppName%"=="" (    echo No application name provided    exit /b 1)REM Check the action before executingif /i "%ACTION%"=="start" (    call :Start) else if /i "%ACTION%"=="stop" (    call :Stop) else if /i "%ACTION%"=="restart" (    call :Restart) else if /i "%ACTION%"=="status" (    call :Status) else (    echo Invalid action. Valid actions are: {start|stop|restart|status}    exit /b 1)goto :eof:StartREM Check if the program is already running using jpsfor /f "tokens=1" %%i in ('jps -l ^| findstr %AppName%') do set PID=%%iif defined PID (    echo %AppName% is already running with PID %PID%...) else (    start "" /b javaw %JVM_OPTS% -jar %AppName%    echo Start %AppName% success...)goto :eof:Stopset "PID="REM Find the process using jps and stop itfor /f "tokens=1" %%i in ('jps -l ^| findstr %AppName%') do (    set "PID=%%i")REM Removing any extra spaces from PID (just in case)for /f "tokens=* delims= " %%i in ("%PID%") do set "PID=%%i"REM Verify if PID is definedif defined PID (    REM Using TASKKILL to kill the process    taskkill /PID %PID% /T /F    REM Check if taskkill was successful    if %errorlevel% NEQ 0 (        echo Failed to stop %AppName% with PID %PID%. Error level: %errorlevel%    ) else (        echo %AppName% with PID %PID% has been stopped.    )) else (    echo %AppName% is already stopped or not running.)goto :eof:Restartcall :Stoptimeout /t 2 >nulcall :Startgoto :eof:StatusREM Check if the program is running using jpsfor /f "tokens=1" %%i in ('jps -l ^| findstr %AppName%') do set PID=%%iif defined PID (    echo %AppName% is running with PID %PID%...) else (    echo %AppName% is not running...)goto :eof
 |