我尝试使用Apache Commons Procrun将JAR文件安装为Windows服务。服务已安装,但执行它会给我以下错误:
[2018-02-26 14:00:26] [info] [38792] Starting service...
[2018-02-26 14:00:26] [error] [38792] Missing service ImageFile
[2018-02-26 14:00:26] [error] [38792] ServiceStart returned 1
[2018-02-26 14:00:26] [info] [38816] Run service finished.
[2018-02-26 14:00:26] [info] [38816] Commons Daemon procrun finished
我的配置看起来像(它在批处理文件中):
set SERVICE_NAME=Deamon
set BASE=c:\GIT\companyProject\myProject
set PR_INSTALL=%BASE%\deamon\prunsrv.exe
REM Service log configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=c:\Logs\Deamon\logs
set PR_STDOUTPUT=c:\Logs\Deamon\stdout.txt
set PR_STDERROR=c:\Logs\Deamon\stderr.txt
set PR_LOGLEVEL=Error
REM Path to java installation
set PR_JVM=%BASE%\jre1.8.0_151\bin\java.exe
set PR_CLASSPATH=%BASE%\target\myProject.jar
REM Startup configuration
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=com.myProject.deamon.Main
set PR_STARTMETHOD=start
REM Shutdown configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=com.myProject.deamon.Main
set PR_STOPMETHOD=stop
REM JVM configuration
set PR_JVMMS=256
set PR_JVMMX=4000
set PR_JVMSS=8000
set PR_JVMOPTIONS=-Duser.language=DE;-Duser.region=de
REM Install service
deamon\%SERVICE_NAME%.exe //IS//%SERVICE_NAME%
在SO上有类似的问题,但我找不到任何“缺少服务ImageFile”错误的答案(也没有关于此主题的官方文档)。虽然我认为自己在编码方面有点经验,但我不知道这个错误来自哪里。任何帮助将不胜感激。
答案 0 :(得分:0)
通过将以下内容添加到您的配置service.bat中,我克服了这一点:
set PR_STARTIMAGE=C:\procrun\itiIcon.ico
set PR_STOPIMAGE=C:\procrun\itiIcon.ico