Questo contenuto non è disponibile nella lingua selezionata.
2.4.2. Running the JBoss ON Server as a Service
The JBoss ON server, storage node and agent can be managed and run as a SysV style init service on Red Hat Enterprise Linux using the following example:
Create a initalization scipt /etc/init.d/jboss-on:
Example Red Hat JBoss Operations Network init script
chkconfig: - 95 20
description: Red Hat JBoss Operations Network rhqctl services
processname: standalone.sh
This is an example script that can be used with a SysV style
init service which starts a JBoss ON server, storage node, and
agent using the rhqctl script provided by the JBoss ON server
installation.
If available, the following files will be sourced, in order, for
configuration. This means that if the same value is defined in a later
file, it will override the one specified in an earlier one:
/etc/jboss-on.conf
/etc/jboss-on/${prog}.conf
The following environment variables can be defined:
RHQ_HOME -- Defaults to /opt/jboss/jboss-on
RHQ_SERVER_HOME -- Defaults to RHQ_HOME/jon-server-*
RHQ_AGENT_HOME -- Defaults to RHQ_HOME/rhq-agent
RHQ_JAVA_HOME -- Defaults to /usr
RHQ_USER -- Defaults to jonadmin
If available, source environment variables for the service
Global defaults/settings
Settings specific to this service
If not yet set, use some reasonable defaults:
We have to export these variables so that they are available to child
processes.
This is a convenient function that invokes rhqctl
We invoke rhqctl differently if start or stop is used so we need this
case statement to determine what should happen.
#!/bin/sh
#
# Example Red Hat JBoss Operations Network init script
#
# chkconfig: - 95 20
# description: Red Hat JBoss Operations Network rhqctl services
# processname: standalone.sh
#
#
# This is an example script that can be used with a SysV style
# init service which starts a JBoss ON server, storage node, and
# agent using the rhqctl script provided by the JBoss ON server
# installation.
prog="`basename "$0"`"
# If available, the following files will be sourced, in order, for
# configuration. This means that if the same value is defined in a later
# file, it will override the one specified in an earlier one:
#
# /etc/jboss-on.conf
# /etc/jboss-on/${prog}.conf
#
# The following environment variables can be defined:
#
# RHQ_HOME -- Defaults to /opt/jboss/jboss-on
# RHQ_SERVER_HOME -- Defaults to RHQ_HOME/jon-server-*
# RHQ_AGENT_HOME -- Defaults to RHQ_HOME/rhq-agent
# RHQ_JAVA_HOME -- Defaults to /usr
# RHQ_USER -- Defaults to jonadmin
#
# If available, source environment variables for the service
# Global defaults/settings
[ -r "/etc/jboss-on.conf" ] && . "/etc/jboss-on.conf"
# Settings specific to this service
[ -r "/etc/jboss-on/${prog}.conf" ] && . "/etc/jboss-on/${prog}.conf"
# If not yet set, use some reasonable defaults:
[ -z "${RHQ_HOME}" ] && RHQ_HOME='/opt/jboss/jboss-on'
[ -z "${RHQ_SERVER_HOME}" ] && RHQ_SERVER_HOME="`eval echo "${RHQ_HOME}/jon-server-"*`"
[ -z "${RHQ_AGENT_HOME}" ] && RHQ_AGENT_HOME="${RHQ_HOME}"'/rhq-agent'
[ -z "${RHQ_JAVA_HOME}" ] && RHQ_JAVA_HOME='/usr'
[ -z "${RHQ_USER}" ] && RHQ_USER=jonadmin
# We have to export these variables so that they are available to child
# processes.
export RHQ_SERVER_HOME
export RHQ_AGENT_HOME
export RHQ_JAVA_HOME
# This is a convenient function that invokes rhqctl
rhqctl() {
RHQCTL_SCRIPT="${RHQ_SERVER_HOME}/bin/rhqctl"
[ ! -x "${RHQCTL_SCRIPT}" ] && {
echo >&2 "${RHQCTL_SCRIPT}"' was not found or is not executable.'
exit 2
}
if [ -n "${RHQ_USER}" -a "$(whoami)" != "${RHQ_USER}" ]; then
CMD="su -m ${RHQ_USER} -c '\"${RHQCTL_SCRIPT}\" $@'"
else
CMD="\"${RHQCTL_SCRIPT}\" $@"
fi
eval ${CMD}
}
# We invoke rhqctl differently if start or stop is used so we need this
# case statement to determine what should happen.
case "$1" in
start)
# Because rhqctl is so chatty/verbose we redirect standard output to
# null so we do not see it during system start and stop.
# Additionally, we invoke it in the background as it can block for
# some time during start.
rhqctl "$@" >/dev/null &
;;
stop)
# Because rhqctl is so chatty/verbose we redirect standard output to
# null so we do not see it during system start and stop.
rhqctl "$@" >/dev/null
;;
*)
# Assuming we are not starting or stopping, we will display complete
# output.
rhqctl "$@"
;;
esac
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Change the permissions on the file so it can be executed:
chmod +x /etc/init.d/jboss-on
chmod +x /etc/init.d/jboss-on
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Add the initalization script to chkconfig:
sudo chkconfig --add /etc/init.d/jboss-on
sudo chkconfig --add /etc/init.d/jboss-on
Copy to ClipboardCopied!Toggle word wrapToggle overflow
To indicate that you intend for the script to run system startup and stop during shutdown:
sudo chkconfig jboss-on on
sudo chkconfig jboss-on on
Copy to ClipboardCopied!Toggle word wrapToggle overflow
To override the default values for RHQ_HOME, RHQ_SERVER_HOME, RHQ_AGENT_HOME, RHQ_JAVA_HOME and RHQ_USER, create the service configuration file /etc/jboss-on.conf or /etc/jboss-on/<SERVICE NAME>.conf with your specific values:
RHQ_HOME=/usr/share/jboss-on
RHQ_USER=jbosson
RHQ_HOME=/usr/share/jboss-on
RHQ_USER=jbosson
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.
Rendiamo l’open source più inclusivo
Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.
Informazioni su Red Hat
Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.