Correct use of DependsOn option in Procrun from Commons Daemon

2.1k views Asked by At

I have a java application running as a windows service using procrun from Commons Daemon. It is running on Windows XP SP3.

The application depends on ActiveMQ, and I installed the service via the following batch script

@echo off

if "%OS%" == "Windows_NT" setlocal

set "APPLICATION_SERVICE_HOME=%cd%"
set EXECUTABLE_NAME=TestGenerator.exe
set EXECUTABLE=%APPLICATION_SERVICE_HOME%\%EXECUTABLE_NAME%
set SERVICE_NAME=TestGenerator

set CG_START_CLASS=net.test.testgenerator.startup.TestGeneratorApp
set CG_STOP_CLASS=%CG_START_CLASS%
set CG_START_METHOD=controlTestGeneratorService
set CG_STOP_METHOD=%CG_START_METHOD%
set CG_START_PARAMS=start
set CG_STOP_PARAMS=stop
set CG_DEPENDS_ON=ActiveMQ
set CG_STARTUP_TYPE=auto

set PR_DESCRIPTION=Test Generator v1.0
set "PR_INSTALL=%EXECUTABLE%"
set "PR_LOGPATH=%APPLICATION_SERVICE_HOME%\logs"
set  "PR_CLASSPATH=%APPLICATION_SERVICE_HOME%;%APPLICATION_SERVICE_HOME%\testgenerator.jar;%APPLICATION_SERVICE_HOME%\lib"
set PR_DISPLAYNAME=Test Generator Service

echo Installing service '%SERVICE_NAME%' ...

"%EXECUTABLE%" //IS//%SERVICE_NAME%  --Startup %CG_STARTUP_TYPE%  --StartClass %CG_START_CLASS% --StopClass %CG_STOP_CLASS% 
"%EXECUTABLE%" //US//%SERVICE_NAME% --StartMode jvm --StopMode jvm --DependsOn %CG_DEPENDS_ON% 
"%EXECUTABLE%" //US//%SERVICE_NAME% --StartMethod %CG_START_METHOD% --StopMethod  %CG_STOP_METHOD% 
"%EXECUTABLE%" //US//%SERVICE_NAME% --StartParams %CG_START_PARAMS% --StopParams %CG_STOP_PARAMS% 
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%APPLICATION_SERVICE_HOME%\temp;" --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' was installed.

However, ActiveMQ does not show up as a dependency in the Administrative Tools\Services Dependencies tab.

When I look at HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\TestGenerator\Parameters, it has the DependsOn key correctly set to ActiveMQ, but the DependsOnService key in HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\TestGenerator\Parameters does not have ActiveMQ listed.

I am able to set the dependency using SC.exe, but it does not allow me to specify all of the other parameters above.

Can anyone tell me if they have been able to successfully use DependsOn with Procrun and, if so, what am I doing incorrectly?

1

There are 1 answers

0
Ulrich Palha On BEST ANSWER

I finally figured out that the --DependsOn option, together with a few others e.g. --Startup only work with the //IS or install command and not the //US or update command.

In the example above moving the --DependsOn option to the //IS command would solve the issue

"%EXECUTABLE%" //IS//%SERVICE_NAME%  --Startup %CG_STARTUP_TYPE%  --StartClass %CG_START_CLASS% --StopClass %CG_STOP_CLASS% --DependsOn %CG_DEPENDS_ON% 

If anyone else has issues with using procrun I wrote up a few instructions, including this issue.