Search

2.4. Starting the JBoss ON Server

download PDF
The JBoss ON server is actually a customized JBoss AS server, included in the JBoss ON installation, so starting the JBoss ON server means starting that JBoss instance.
The JBoss ON server can be started manually or can be configured to start and run as a system service.

2.4.1. Starting the JBoss ON Server (Basic)

The JBoss ON server process is started by running the rhqctl script in the serverRoot/bin/ directory.
Important
The JBoss ON server cannot start or restart itself through a resource operation in the command line or UI (unlike other EAP resources). The JBoss ON UI or CLI for one server can be used to start another JBoss ON server in the cloud, but it cannot be perform a start or restart operation reflexively.
The simplest way to start the server is simply to run the script with the start command. This starts the server process and then exits from the script.
serverRoot/bin/rhqctl start --server
Trying to start the RHQ Server...
RHQ Server (pid 27547) is starting
The rhqctl script looks for specific environment variables during its execution, especially related to the JVM to use with the JBoss EAP server instance. A complete list of environment variables is given in the script itself; defaults based on the installation information are used, so most environment variables don't need to be reset.
Note
The RHQ_JAVA_HOME environment variable must be set on Red Hat Enterprise Linux systems for the server to start. This can be set to a general value like /usr/.
The server can also be started in console mode, which prints detailed information about the server process to the terminal and leaves the script open as long as the server is running.
[root@server ~]# ./rhqctl console --server
20:28:44,120 INFO  [org.jboss.modules] JBoss Modules version 1.2.2.Final-redhat-1
Starting RHQ Server in console...
JAVA_OPTS already set in environment; overriding default settings with values: -
....

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
    
  2. Change the permissions on the file so it can be executed:
    sudo chmod +x /etc/init.d/jboss-on
  3. Add the initalization script to chkconfig:
    sudo chkconfig --add /etc/init.d/jboss-on
  4. To indicate that you intend for the script to run system startup and stop during shutdown:
    sudo chkconfig jboss-on on
  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
    
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.