Red Hat Training

A Red Hat training course is available for Red Hat JBoss Operations Network

8.4. Running the JBoss ON Agent as a Service

In almost all production environments, the agent should be started as a background daemon process. On Windows, this runs as a service. On Linux and Unix systems, the agent starts at boot time from init.d.
More detail on editing the agent server wrapper script and managing the agent daemon is covered in the Configuring JBoss ON Servers and Agents guide.

8.4.1. Running the Agent as a Windows Service

The default Java service wrapper included with JBoss ON requires a 32-bit JVM, so the Java preference set for the agent must be a 32-bit JRE. The JBoss ON agent must use a 32-bit JVM even on 64-bit systems.
Running the agent with a 32-bit JVM does not in any way affect how JBoss ON manages other resources which may run with a 64-bit JVM. JBoss ON can still manage those resources and those resources can still use the 64-bit Java libraries for their own processes.
  1. Make sure the agent is fully set up. The agent does not prompt for the configuration when it is started as a service.
  2. Edit the rhq-agent-wrapper.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 overrides RHQ_AGENT_RUN_AS.


    Before setting RHQ_AGENT_RUN_AS_ME or RHQ_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 the rhq-agent-wrapper.bat script.
  3. Run the rhq-agent-wrapper.bat script to install the init script as a service. Use the install command to install the init script.
  4. When prompted, fill in the password for the system user as whom the service will run.

8.4.2. Running the Agent as a Daemon or init.d Service

  1. Make sure the agent is fully set up. The agent does not prompt for the configuration when it is started as a service.
  2. Open the file.
  3. Uncomment and configure the required environment variables for the agent's bin directory, the JDK directory, and the PID directory (which must be writable by the agent user).
    export RHQ_AGENT_JAVA_HOME=/usr


    When setting the PIDFILEDIR on Red Hat Enterprise Linux, edit the pidfile setting in the script file. The wrapper script value is used by chkconfig.
  4. Set any of the optional environment variables.
    • RHQ_AGENT_DEBUG enables debug logging.
    • RHQ_AGENT_JAVA_EXE_FILE_PATH specifies a Java executable.
    • RHQ_AGENT_JAVA_OPTS passes settings to the agent JVM.
    • RHQ_AGENT_ADDITIONAL_JAVA_OPTS passes additional Java options to the JVM.
  5. Log into the system as root.


    The rest of this procedure describes how to configure the agent init script as a service on Red Hat Enterprise Linux. For other Unix systems, follow a similar procedure that corresponds to the specific platform.
  6. Make sure the wrapper script is executable.
    [root@server rhq-agent]# chmod a+x agentRoot/rhq-agent/bin/
  7. Symlink the file to /etc/init.d/. For example:
    [root@server rhq-agent]# ln -s agentRoot/rhq-agent/bin/ /etc/init.d/


    On Solaris, symlinking the agent script file requires invoking readlink in readlink is not supplied by default in some Solaris installations. Solaris users must download readlink from a source such as Sunfreeware.
  8. Register with chkconfig.
    [root@server rhq-agent] # /sbin/chkconfig --add
  9. Enable the agent service to run at boot time and have it stop gracefully at when the system shuts down.
    [root@server rhq-agent] # /sbin/chkconfig on
If the agent service should not be started when the system boots, turn the script off in chkconfig:
[root@server rhq-agent] # /sbin/chkconfig off