Existem alguns recursos já prontos no Red Hat Cluster Suite (RHCS) para serem adicionados como serviço. Mas também é possível acrescentar seu próprio script para que o RHCS realoque ou reinicie o serviço em questão.
Basicamente o script tem que conter 3 chamadas: status, start e stop.
Abaixo está um exemplo que inicia, pára e verifica o status do Sun Glassfish, fique a vontade em adaptar a sua necessidade.
#!/bin/sh
# Script Name: glassfish
# Script Path: /etc/init.d/glassfish
# Script Purpose: To provide glassfish management
# start/stop/status under Red Hat Cluster Cluster
# Script Author: Daniel K. Lima
BASEDIR=/opt/glassfish/bin
case $1 in
'start')
cd ${BASEDIR}
./asadmin start-domain domain1
exit 0
;;
'stop')
z=$(ps -ef | grep "com.sun.aas" | grep -v "grep"| awk ' { print $2 } ')
if [[ $? -eq 0 ]]
then
cd ${BASEDIR}
./asadmin stop-domain domain1
exit 0
fi
;;
'restart')
/etc/init.d/glassfish stop
sleep 2
echo Now starting......
/etc/init.d/glassfish start
echo "restarted"
;;
'status')
ps awx | grep -v "grep " | grep "com.sun.aas" 1>/dev/null
if [[ $? = 0 ]]
then
echo "Glassfish is running..."
exit 0
else
echo "Glassfish is stopped..."
exit 1
fi
;;
esac

Join the conversation