Skip to content

Instantly share code, notes, and snippets.

@sebastianwebber
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sebastianwebber/885b620bdf9dde39eadf to your computer and use it in GitHub Desktop.
Save sebastianwebber/885b620bdf9dde39eadf to your computer and use it in GitHub Desktop.
JBoss AS7+/EAP 6+ Control Script for DomainMode on EL6 platform
#!/bin/bash
#
# chkconfig: 345 60 40
#
# JBoss AS7+/EAP 6+ Control Script for DomainMode on EL6 platform
#
# Developped by:
# Sebastian Webber - http://swebber.me
# Last update:
# 2014-10-30
#
## DEFAULT SETTINGS ###########################################
JBOSS_HOME="/opt/jboss-eap-6.3"
JBOSS_INSTANCE_PARMS=""
#JBOSS_INSTANCE_PARMS="${JBOSS_INSTANCE_PARMS} -Djboss.host.default.config=host-slave.xml"
#JBOSS_INSTANCE_PARMS="${JBOSS_INSTANCE_PARMS} -Djboss.domain.master.address=10.0.0.1"
SERVICE_USER="jboss"
## STOP EDITING HERE ###########################################
. /etc/init.d/functions
function get_pid() {
java_pid=$(ps u -C java | grep '\[Process Controller\]' | awk '{print $2}')
echo ${java_pid}
}
function do_stop() {
current_pid=$( get_pid )
if [ "${current_pid}X" = "X" ]; then
warning ; echo "Process controller is NOT running..."
else
echo -n -e "Stopping the process controler."
kill -15 ${current_pid}
while [ "${current_pid}X" != "X" ]; do
sleep 1
echo -n -e "."
current_pid=$( get_pid )
done
success ; echo "Process controler was stopped..."
fi
}
function do_start() {
current_pid=$( get_pid )
if [ "${current_pid}X" != "X" ]; then
warning ; echo "Process controller is already running..."
else
console_log_dir="${JBOSS_HOME}/domain/log"
if [ ! -d "${console_log_dir}" ]; then
mkdir -p ${console_log_dir}
chown -R ${SERVICE_USER}:${SERVICE_USER} ${console_log_dir}
fi
echo -n -e "Starting process controller..."
_console_log="${console_log_dir}/console.log"
touch ${_console_log}
chown ${SERVICE_USER}:${SERVICE_USER} ${_console_log}
_cmd="${JBOSS_HOME}/bin/domain.sh ${JBOSS_INSTANCE_PARMS} > ${_console_log} 2>&1 &"
su - ${SERVICE_USER} -c "${_cmd}"
if [ $? -eq 0 ]; then
sleep 3 && show_status
else
failure ; echo "Process controller fail to start..."
fi
fi
}
function show_status() {
java_pid=$( get_pid )
if [ "${java_pid}X" != "X" ]; then
success ; echo "Process controller is running in ${java_pid} process..."
else
warning ; echo "Process controller is NOT running..."
fi
}
function show_usage() {
this_script=$(basename ${0})
echo "Usage: ${this_script} (start|stop|restart|status|help)"
}
case "${1}" in
start) do_start ;;
stop) do_stop;;
restart) do_stop ; do_start ;;
status) show_status ;;
*) show_usage ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment