sudo nano /etc/init.d/glassfish2. Write the lines below into the file and save it
#! /bin/sh
#to prevent some possible problems
export AS_JAVA=jdk path
GLASSFISHPATH= glashfish bin path
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1
;;
*)
echo $"usage: $0 {start|stop|restart}"
exit 3
;;
esac
:
Example
#! /bin/sh
#to prevent some possible problems
export AS_JAVA=/home/sdsl/jdk1.7.0_07
GLASSFISHPATH=/home/sdsl/glassfish3/bin
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
sudo $GLASSFISHPATH/asadmin start-domain domain1
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
sudo $GLASSFISHPATH/asadmin stop-domain domain1
;;
*)
echo $"usage: $0 {start|stop|restart}"
exit 3
;;
esac
:
3. Make the init script file executable
sudo chmod a+x /etc/init.d/glassfish4. Configure Glassfish for autostart on ubuntu boot
sudo update-rc.d glassfish defaults6. Start, stop or restart Glassfish server
Start
service glassfish startStop
service glassfish stopRestart
service glassfish restart
thanks a lot i really appreciate that
ReplyDeleteThanks
Deletewhy don't you have an export statement before your GLASSFISH environment variable?
ReplyDeleteI guess it's a bit late for an answer to this question, but the variable is only needed for the script itself. In contrast, the AS_JAVA variable is needed by child processes as well.
Delete@Hiro: Thanks, still a very helpful post!
permission denied. what to do
ReplyDelete