javawindowsserviceprocrun

procrun "cannot find registry key for service 'prunsrv'"


I'm trying to run my application (which is in a fat jar) as a service on windows using procrun. Specifically my dev system is Server 2012. I have created a batch file like all the examples I have seen, but when I try to run it (or even just run prunsrv.exe by itself) I get the following error

c:\Users\kmilner\Desktop>c:\seven10\procrun\amd64\prunsrv
[2015-12-22 14:42:47] [warn]  [ 3132] The system cannot find the Registry key for service 'prunsrv'
[2015-12-22 14:42:47] [error] [ 3132] Load configuration failed
[2015-12-22 14:42:47] [error] [ 3132] The system cannot find the file specified.
[2015-12-22 14:42:47] [error] [ 3132] Commons Daemon procrun failed with exit value: 2 (Failed to load configuration)
[2015-12-22 14:42:47] [error] [ 3132] The system cannot find the file specified.

I cannot figure out why it is assigning the service name to the name of the executable. Here is the batch file I wrote, but again, I get the same response when I just run the prunsrv.exe without any parameters.

@cls
@if not "%1" == "" (
     @set PROCRUN_CMD=%1
) else (
     @set PROCRUN_CMD=TS
)

set APP_HOME=c:\myapp
set AGENT_HOME=%APP_HOME%\agent

set PROCRUN_EXEC=%APP_HOME%\procrun\amd64\prunsrv.exe

set AGENT_SERVICE_NAME=My-Agent

set SERVICE_LOG_PATH=%AGENT_HOME%\logs\windows

%PROCRUN_EXEC% %PROCRUN_CMD% %AGENT_SERVICE_NAME% ^
    --Install="%PROCRUN_EXEC%" ^
    --Description="My Service" ^
    --Classpath="%AGENT_HOME%\MyApp.jar" ^
    --StartClass=org.MyOrg.MyApp ^
    ++startParams="-s;%AGENT_HOME%\conf\settings.json" ^
    --StartMode="java" ^
    --Startup="auto" ^
    --StopClass=java.lang.System ^
    --StopMethod=exit ^
    --StopMode=jvm ^
    --logPath="%SERVICE_LOG_PATH%" ^
    --StdOutput="%SERVICE_LOG_PATH%\service-stdout.txt" ^
    --StdError="%SERVICE_LOG_PATH%\service-stderr.txt" ^
    --LogLevel="Debug"

@echo.

So what am I missing here that is causing this problem? I can find no other answers.


Solution

  • The reason it was doing this is because I didn't have the //s around the procrun command. :( Also, as my awesome boss pointed out, the case is wrong on startParams and logPath. My bad. But maybe it will help someone else in this exact same situation.