此内容没有您所选择的语言版本。
4.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.
4.4.1. Running the Agent as a Windows Service 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
- Make sure the agent is fully set up. The agent does not prompt for the configuration when it is started as a service.
- Edit the
rhq-agent-wrapper.batscript and set the environment variable to define the system user as whom the init script will run. There are two options:RHQ_AGENT_RUN_ASexplicitly sets the user account name. This must match the format of a Windows user account name, DOMAIN\username.RHQ_AGENT_RUN_AS_MEforces 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_MEorRHQ_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.batscript. - Run the
rhq-agent-wrapper.batscript to install the init script as a service. Use theinstallcommand to install the init script. - When prompted, fill in the password for the system user as whom the service will run.
4.4.2. Running the Agent as a Daemon or init.d Service 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
- Make sure the agent is fully set up. The agent does not prompt for the configuration when it is started as a service.
- Open the
rhq-agent-env.shfile. - Uncomment and configure the required environment variables for the agent's
bindirectory, the JDK directory, and the PID directory (which must be writable by the agent user).RHQ_AGENT_HOME=agentRoot/rhq-agent/ export RHQ_AGENT_JAVA_HOME=/usr PIDFILEDIR=/var/run
RHQ_AGENT_HOME=agentRoot/rhq-agent/ export RHQ_AGENT_JAVA_HOME=/usr PIDFILEDIR=/var/runCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note
When setting thePIDFILEDIRon Red Hat Enterprise Linux, edit thepidfilesetting in therhq-agent-wrapper.shscript file. The wrapper script value is used bychkconfig. - Set any of the optional environment variables.
RHQ_AGENT_DEBUGenables debug logging.RHQ_AGENT_JAVA_EXE_FILE_PATHspecifies a Java executable.RHQ_AGENT_JAVA_OPTSpasses settings to the agent JVM.RHQ_AGENT_ADDITIONAL_JAVA_OPTSpasses additional Java options to the JVM.
- Log into the system as root.
Important
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. - Make sure the wrapper script is executable.
chmod a+x agentRoot/rhq-agent/bin/rhq-agent-wrapper.sh
[root@server rhq-agent]# chmod a+x agentRoot/rhq-agent/bin/rhq-agent-wrapper.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Symlink the
rhq-agent-wrapper.shfile to/etc/init.d/. For example:ln -s agentRoot/rhq-agent/bin/rhq-agent-wrapper.sh /etc/init.d/rhq-agent-wrapper.sh
[root@server rhq-agent]# ln -s agentRoot/rhq-agent/bin/rhq-agent-wrapper.sh /etc/init.d/rhq-agent-wrapper.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow Important
On Solaris, symlinking the agent script file requires invokingreadlinkinrhq-agent-wrapper.sh.readlinkis not supplied by default in some Solaris installations. Solaris users must downloadreadlinkfrom a source such as Sunfreeware. - Register
rhq-agent-wrapper.shwithchkconfig.[root@server rhq-agent] # /sbin/chkconfig --add rhq-agent-wrapper.sh
[root@server rhq-agent] # /sbin/chkconfig --add rhq-agent-wrapper.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 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 rhq-agent-wrapper.sh on
[root@server rhq-agent] # /sbin/chkconfig rhq-agent-wrapper.sh onCopy to Clipboard Copied! Toggle word wrap Toggle overflow
If the agent service should not be started when the system boots, turn the script off in
chkconfig:
[root@server rhq-agent] # /sbin/chkconfig rhq-agent-wrapper.sh off
[root@server rhq-agent] # /sbin/chkconfig rhq-agent-wrapper.sh off