Monday, November 23, 2009

JBoss setup for Solaris

Old style, before SMF

/etc/init.d/jboss
====================================
#!/sbin/sh
JBOSS_HOME=/u05/app/jboss-5.0.1.GA
JAVA_HOME=/u05/app/java6/jre1.6.0_02
case "$1" in
start)
cd $JBOSS_HOME/bin
echo "Staring jboss daemon: "
nohup $JBOSS_HOME/bin/run.sh &
;;
stop)
cd $JBOSS_HOME/bin
echo "Stopping jboss daemon: "
$JBOSS_HOME/bin/shutdown.sh -S
;;
restart)
cd $JBOSS_HOME/bin
echo "Restarting jboss daemon: "
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage $0 {startstoprestart}"
exit 1
;;
esac
exit 0
===================================
/etc/rc3.d/S99jboss -> /etc/init.d/jboss
/etc/rcS.d/K07jboss -> /etc/init.d/jboss

With Solaris 10 SMF

The Solaris 10 OS uses the Service Management Facility (SMF) to handle services.

Create a service manifest file:/var/svc/manifest/network/jboss4.xml




name='network/jboss'
type='service'
version='1'>




name='fs'
grouping='require_all'
restart_on='none'
type='service'>
value='svc:/system/filesystem/local' />




grouping='require_all'
restart_on='none'
type='service'>
value='svc:/network/loopback' />


name='ssh_multi-user-server'
grouping='optional_all'
restart_on='none'>
value='svc:/milestone/multi-user-server' />


type='method'
name='start'
exec='/lib/svc/method/svc-jboss4 start'
timeout_seconds='-1'>




type='method'
name='stop'
exec=':kill'
timeout_seconds='-1'>


type='method'
name='restart'
exec='/lib/svc/method/svc-jboss4 restart'
timeout_seconds='-1'>









Now create your "Service Method File" in /lib/svc/method called svc-jboss4:

#!/usr/bin/sh
# William Pool (Puddle) 01/05
# SMF Method file for JBoss
# E-mail: puddle@flipmotion.com
#
# NOTE: If you start JBoss with su -c 'cmds' instead
# You "will" be able to start and stop it via root using the method file
# itself. However, it "does" confuse SMF. It's best to have the straight
# commands and let the actual SMF service do the user rights and permissions
# of execution. You've been WARNED! Use su -c 'cmds' at your own risk!
#
. /lib/svc/share/smf_include.sh
case $1 in
'start')
echo "starting jboss.."
/opt/software/jboss-4.0.1/bin/run.sh & >/dev/null 2> /dev/null
;;
'stop')
echo "stopping jboss.."
/opt/software/jboss-4.0.1/bin/shutdown.sh -S &
pkill java
;;
'restart')
stop
# give stuff some time to stop before we restart
sleep 35
# protect against any services that can't stop before we restart (warning
this kills all Java instances running as 'jboss' user)
pkill java
start
;;
*)
echo "Usage: $0 { start stop restart }"
exit 1
;;
esac
#---EOF

Now fix the permissions for the two files created:

chown root:bin /lib/svc/method/svc-jboss4
chmod 555 /lib/svc/method/svc-jboss4
chown root:sys /var/svc/manifest/network/jboss4.xml
chmod 444 /var/svc/manifest/network/jboss4.xml

Import the service into the service repository:
# svccfg import /var/svc/manifest/network/jboss4.xml
Enable the service:
# svcadm -v enable jboss

No comments: