Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

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:
  1. Create a initalization scipt /etc/init.d/jboss-on:
    #!/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 Clipboard Toggle word wrap
  2. Change the permissions on the file so it can be executed:
    chmod +x /etc/init.d/jboss-on
    Copy to Clipboard Toggle word wrap
  3. Add the initalization script to chkconfig:
    sudo chkconfig --add /etc/init.d/jboss-on
    Copy to Clipboard Toggle word wrap
  4. To indicate that you intend for the script to run system startup and stop during shutdown:
    sudo chkconfig jboss-on on
    Copy to Clipboard Toggle word wrap
  5. 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
    
    Copy to Clipboard Toggle word wrap
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat