Win10 registers zookeeper as a service, starts normally, stops Times error "system error 1067, process terminates unexpectedly"

follow the online tutorials to register zookeeper under win10 as a service, where install.bat and zkServerStop.cmd are shown as follows
install.bat

prunsrv.exe "//IS//%ZOOKEEPER_SERVICE%" ^
        --DisplayName="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
        --Description="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
        --Startup=auto --StartMode=exe ^
        --StartPath=%ZOOKEEPER_HOME% ^
        --StartImage=%ZOOKEEPER_HOME%\bin\zkServer.cmd ^
        --StopPath=%ZOOKEEPER_HOME%\ ^
        --StopImage=%ZOOKEEPER_HOME%\bin\zkServerStop.cmd ^
        --StopMode=exe --StopTimeout=5 ^
        --LogPath=%ZOOKEEPER_HOME% --LogPrefix=zookeeper-wrapper ^
        --PidFile=zookeeper.pid --LogLevel=Info --StdOutput=auto --StdError=auto

zkServerStop.cmd

@echo off
setlocal
TASKLIST /svc | findstr /c:"%ZOOKEEPER_SERVICE%" > %ZOOKEEPER_HOME%\zookeeper_svc.pid
FOR /F "tokens=2 delims= " %%G IN (%ZOOKEEPER_HOME%\zookeeper_svc.pid) DO (
    @set zkPID=%%G
)
taskkill /PID %zkPID% /T /F
del %ZOOKEEPER_HOME%/zookeeper_svc.pid
endlocal

now you can start the service normally by using net start zkServer , but if you use net stop zkServer , you will get an error

.

the feeling is caused by the direct use of taskkill. Although zookeeper, can also be closed, it always feels that it is not good to force it to close. Ask for advice, how can we make zookeeper start and stop normally like a normal service?

Apr.01,2021
Menu