我有一个基于Spring-boot的小应用程序,我试图使用procrun注册为Windows服务。不幸的是,procrun似乎未能启动我的应用程序。
这是我的主要课程:
public class Daemon {
public static void main(String[] args) throws IOException {
if ("start".equals(args[0])) {
start(args);
} else if ("stop".equals(args[0])) {
stop(args);
}
}
public static void start(String[] args) {
Application.main(new String[0]);
}
public static void stop(String[] args) {
}
}
这是我的安装蝙蝠:
set "CURRENT_DIR=%cd%"
set "APPLICATION_SERVICE_HOME=%cd%"
echo %APPLICATION_SERVICE_HOME%
set SERVICE_NAME=cmsapi
set EXECUTABLE_NAME=%SERVICE_NAME%.exe
set EXECUTABLE=%APPLICATION_SERVICE_HOME%\%EXECUTABLE_NAME%
set CG_START_CLASS=com.castsoftware.analyser.Daemon
set CG_STOP_CLASS=%CG_START_CLASS%
set CG_PATH_TO_JAR_CONTAINING_SERVICE=%APPLICATION_SERVICE_HOME%\..\..\CAST-CMSAPI.jar
set CG_STARTUP_TYPE=auto
set PR_CLASSPATH=%APPLICATION_SERVICE_HOME%;%CG_PATH_TO_JAR_CONTAINING_SERVICE%
set CG_PATH_TO_JVM="%JAVA_HOME%\jre\bin\server\jvm.dll"
set EXECUTE_STRING= %EXECUTABLE% //IS//%SERVICE_NAME% --Startup %CG_STARTUP_TYPE% --StartClass %CG_START_CLASS% --StopClass %CG_STOP_CLASS%
call %EXECUTE_STRING%
set EXECUTE_STRING= "%EXECUTABLE%" //US//%SERVICE_NAME% --StartMode jvm --StopMode jvm --Jvm %CG_PATH_TO_JVM%
call %EXECUTE_STRING%
set EXECUTE_STRING= "%EXECUTABLE%" //US//%SERVICE_NAME% --StartMethod %CG_START_METHOD% --StopMethod %CG_STOP_METHOD%
call %EXECUTE_STRING%
set EXECUTE_STRING= "%EXECUTABLE%" //RS//%SERVICE_NAME%
call %EXECUTE_STRING%
echo The service '%SERVICE_NAME%' has been installed.
pause
以下是我目前获得的日志:
[2016-04-25 10:02:36] [info] [85088] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-04-25 10:02:36] [info] [85088] Service cmsapi name
[2016-04-25 10:02:36] [info] [85088] Service 'cmsapi' installed
[2016-04-25 10:02:36] [info] [85088] Commons Daemon procrun finished
[2016-04-25 10:02:37] [info] [80396] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-04-25 10:02:37] [info] [80396] Updating service...
[2016-04-25 10:02:37] [warn] [80396] Failed to obtain service description
[2016-04-25 10:02:37] [info] [80396] Service 'cmsapi' updated
[2016-04-25 10:02:37] [info] [80396] Update service finished.
[2016-04-25 10:02:37] [info] [80396] Commons Daemon procrun finished
[2016-04-25 10:02:38] [info] [70552] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-04-25 10:02:38] [info] [70552] Updating service...
[2016-04-25 10:02:38] [warn] [70552] Failed to obtain service description
[2016-04-25 10:02:38] [info] [70552] Service 'cmsapi' updated
[2016-04-25 10:02:38] [info] [70552] Update service finished.
[2016-04-25 10:02:38] [info] [70552] Commons Daemon procrun finished
[2016-04-25 10:02:38] [info] [82616] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-04-25 10:02:38] [info] [82616] Running 'cmsapi' Service...
[2016-04-25 10:02:38] [error] [82616] StartServiceCtrlDispatcher for 'cmsapi' failed
[2016-04-25 10:02:38] [error] [82616] The service process could not connect to the service controller.
[2016-04-25 10:02:38] [error] [82616] Commons Daemon procrun failed with exit value: 4 (Failed to run service)
[2016-04-25 10:02:38] [error] [82616] The service process could not connect to the service controller.
[2016-04-25 10:03:08] [info] [ 8024] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-04-25 10:03:08] [info] [ 8024] Running 'cmsapi' Service...
[2016-04-25 10:03:08] [info] [85752] Starting service...
[2016-04-25 10:03:08] [error] [85440] FindClass com/castsoftware/analyser/Daemon failed
[2016-04-25 10:03:08] [error] [85752] Failed to start Java
[2016-04-25 10:03:08] [error] [85752] ServiceStart returned 4
[2016-04-25 10:03:08] [info] [ 8024] Run service finished.
[2016-04-25 10:03:08] [info] [ 8024] Commons Daemon procrun finished
所以基本上似乎procrun找不到我的主类,但它就在那里。我不确定此刻我做错了什么