I have a small Spring-boot based application that I'm trying to register as a windows service using procrun. Unfortunately, procrun seems to be failing to start my application.
Here's my Main class:
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) {
}
}
here's my installation bat:
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
and here are the logs that I currently get:
[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
So basically it seems that procrun cannot find my main class, but it's right there. I'm not sure what I'm doing wrong at this point