2.5.3. Configuring the Agent as a Windows Service
- Edit the
rhq-agent-env.bat
script and set the environment variable to define the system user as whom the init script will run. There are two options:RHQ_AGENT_RUN_AS
explicitly sets the user account name. This must match the format of a Windows user account name, DOMAIN\username.RHQ_AGENT_RUN_AS_ME
forces the agent to run as whoever the current user is; this uses the format . \ %USERNAME %. If both environment variables are defined, this variable overridesRHQ_AGENT_RUN_AS
.
Note
Before settingRHQ_AGENT_RUN_AS_ME
orRHQ_AGENT_RUN_AS
, make sure that the given user actually has permission to start services. If necessary, assign the user the appropriate rights. Assigning rights is covered in the Windows documentation.If neither variable is set, the agent init script runs as the System user.Other available environment variables are listed and defined in the comments in therhq-agent-wrapper.bat
script. - Run the
rhq-agent-wrapper.bat
script to install the init script as a service. Use theinstall
command to install the init script. - When prompted, fill in the password for the system user as whom the service will run.
The agent service starts automatically when the Windows system boots. The service can be started or stopped through the Windows Services Administrative Tools.
The agent service can also be started and stopped through the
rhq-agent-wrapper.bat
script using the start
and stop
commands. The status
command shows whether the agent init script is installed as a service and whether it is running. The remove
command removes the agent init script as a service.
The JBoss ON agent Windows scripts use the Java Wrapper Service to control the service. A configuration file, agentRoot
\bin\wrapper\rhq-agent-wrapper.conf
, contains the service configuration properties. These are standard wrapper service properties; more information is available at http://wrapper.tanukisoftware.org/doc/english/properties.html.
There are some common properties to edit to custom the service:
wrapper.app.parameter.#
set command-line options to pass to the agent. These are the same options listed in Section 7.3, “Working with the Agent Command Prompt”. Each option requires its own configuration property. Properties must be placed in numeric order and the first two properties (wrapper.app.parameter.1
andwrapper.app.parameter.2
) are reserved. Start withwrapper.app.parameter.3
.wrapper.java.additional.#
set additional JVM options that are passed directly to the VM, corresponding to the-D
and-X
options. These also must be incremented numerically.wrapper.java.additional.1
always specifies the log configuration file.wrapper.ntservice.starttype
sets when to start the service. The default isAUTO_START
, which starts the service when the system boots. To start the service manually, the value isDEMAND_START
.