Pages

Saturday, May 22, 2010

Setup and Running Glassfish as a service on CentOS

1/ Setup Glassfish
Phải đăng nhập vào mode Graphics mới setup Glassfish duoc.

init 5

- Làm theo hướng dẫn step by step
http://docs.sun.com/app/docs/doc/820-7690



2/ Tạo file Script service


cd etc/init.d/

nano glassfish

copy đoạn script o dưới vào


#!/bin/bash
#
# glassfish: Startup script for Glassfish Application Server.
#
# chkconfig: 3 80 05
# description: Startup script for domain1 of Glassfish Application Server.

GLASSFISH_HOME=/root/glassfishv3/glassfish;
export GLASSFISH_HOME

GLASSFISH_OWNER=root;
export GLASSFISH_OWNER

start() {
echo -n "Starting Glassfish: "
echo "Starting Glassfish at `date`" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
sleep 2
echo "done"
}

stop() {
echo -n "Stopping Glassfish: "
echo "Stopping Glassfish at `date`" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1" >> $GLASSFISH_HOME/domains/domain1/logs/startup.log
echo "done"
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: glassfish {start|stop|restart}"
exit
esac

3/ Install the service

#chmod +x /etc/init.d/glassfish
#chkconfig --add glassfish
#chkconfig --level 3 glassfish on

4/ # Start glassfish.

#/etc/init.d/glassfish start

No comments: