Commons Daemon procrun 失败,退出代码为 5 - "apxServiceControl()" 错误
Commons Daemon procrun fails with exit code 5 - "apxServiceControl()" errors
我正在使用 Apache Commons Procrun(prunsrv.exe,重命名为 testService.exe)将 .jar 安装为 windows 服务。它成功安装了服务,并出现在 Windows 服务管理器中。
当我尝试启动该服务时,它失败了。这是带有相关错误的公共守护程序日志:
[2019-01-14 09:52:52] [info] [12988] Commons Daemon procrun (1.1.0.0 64-bit) started
[2019-01-14 09:52:52] [info] [12988] Starting service 'testService' ...
[2019-01-14 09:52:52] [warn] [12988] Failed to obtain service description
[2019-01-14 09:52:56] [error] [12988] apxServiceControl(): dwState(4) != dwCurrentState(1); dwWin32ExitCode = 1066, dwWaitHint = 0, dwServiceSpecificExitCode = 1
[2019-01-14 09:52:56] [error] [12988] apxServiceControl(): returning FALSE
[2019-01-14 09:52:56] [error] [12988] Failed to start service 'testService'
[2019-01-14 09:52:56] [info] [12988] Start service finished, returning 0
[2019-01-14 09:52:56] [error] [12988] Commons Daemon procrun failed with exit value: 5 (Failed to start service)
这是我编写的脚本,其中 installs/starts 服务:
@echo off
SET SERVICE_NAME=testService
IF "%1%" == "start" GOTO START
IF "%1%" == "stop" GOTO STOP
IF "%1%" == "delete" GOTO DELETE
IF "%1%" NEQ "install" GOTO:EOF
SET PR_INSTALL="%~dp0testService.exe"
SET PR_CLASSPATH=testService.jar
SET PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
SET PR_STARTUP=auto
SET PR_STARTMODE=jvm
SET PR_STARTCLASS=com.testService
SET PR_STARTPARAM=start
SET PR_STOPMODE=jvm
SET PR_STOPCLASS=com.testService
SET PR_STOPPARAM=stop
%SERVICE_NAME%.exe install %SERVICE_NAME%
GOTO:EOF
:START
%SERVICE_NAME%.exe start %SERVICE_NAME%
GOTO:EOF
:STOP
%SERVICE_NAME%.exe stop %SERVICE_NAME%
GOTO:EOF
:DELETE
%SERVICE_NAME%.exe delete %SERVICE_NAME%
知道该错误可能意味着什么吗?我似乎找不到任何关于此的信息,这让我抓狂。
问题出在 %SERVICE_NAME%.exe install %SERVICE_NAME%
个调用
我将它们替换为 testService.exe install %SERVICE_NAME%
并且服务按预期启动。
我正在使用 Apache Commons Procrun(prunsrv.exe,重命名为 testService.exe)将 .jar 安装为 windows 服务。它成功安装了服务,并出现在 Windows 服务管理器中。
当我尝试启动该服务时,它失败了。这是带有相关错误的公共守护程序日志:
[2019-01-14 09:52:52] [info] [12988] Commons Daemon procrun (1.1.0.0 64-bit) started
[2019-01-14 09:52:52] [info] [12988] Starting service 'testService' ...
[2019-01-14 09:52:52] [warn] [12988] Failed to obtain service description
[2019-01-14 09:52:56] [error] [12988] apxServiceControl(): dwState(4) != dwCurrentState(1); dwWin32ExitCode = 1066, dwWaitHint = 0, dwServiceSpecificExitCode = 1
[2019-01-14 09:52:56] [error] [12988] apxServiceControl(): returning FALSE
[2019-01-14 09:52:56] [error] [12988] Failed to start service 'testService'
[2019-01-14 09:52:56] [info] [12988] Start service finished, returning 0
[2019-01-14 09:52:56] [error] [12988] Commons Daemon procrun failed with exit value: 5 (Failed to start service)
这是我编写的脚本,其中 installs/starts 服务:
@echo off
SET SERVICE_NAME=testService
IF "%1%" == "start" GOTO START
IF "%1%" == "stop" GOTO STOP
IF "%1%" == "delete" GOTO DELETE
IF "%1%" NEQ "install" GOTO:EOF
SET PR_INSTALL="%~dp0testService.exe"
SET PR_CLASSPATH=testService.jar
SET PR_JVM=%JAVA_HOME%\jre\bin\server\jvm.dll
SET PR_STARTUP=auto
SET PR_STARTMODE=jvm
SET PR_STARTCLASS=com.testService
SET PR_STARTPARAM=start
SET PR_STOPMODE=jvm
SET PR_STOPCLASS=com.testService
SET PR_STOPPARAM=stop
%SERVICE_NAME%.exe install %SERVICE_NAME%
GOTO:EOF
:START
%SERVICE_NAME%.exe start %SERVICE_NAME%
GOTO:EOF
:STOP
%SERVICE_NAME%.exe stop %SERVICE_NAME%
GOTO:EOF
:DELETE
%SERVICE_NAME%.exe delete %SERVICE_NAME%
知道该错误可能意味着什么吗?我似乎找不到任何关于此的信息,这让我抓狂。
问题出在 %SERVICE_NAME%.exe install %SERVICE_NAME%
个调用
我将它们替换为 testService.exe install %SERVICE_NAME%
并且服务按预期启动。