users@glassfish.java.net

Re: how to start glassfish as windows service or Linux daemon?

From: Wouter van Reeven <wouter_at_van.reeven.nl>
Date: Thu, 16 Nov 2006 12:09:27 +0100

Hi Legolas,

On Thu, Nov 16, 2006 at 02:20:36PM +0330, legolas wood wrote:
> Thank you for reading my post
> how we can start glassfish as a windows service or Linux daemon ?
> indeed first we need to register them as a service and then register the
> service

I don't know about Windows, but on Linux I use the script included below. I have
put it in the /etc/init.d directory. Please note that I have installed glassfish
in the /usr/local/glassfish directory and that all files and directories are
owned by the user glassfish in the group glassfish. I also created a log
directory in /usr/local/glassfish to redirect any system messages to.

Preferably I would create a package (Debian in my case) to install it in a
system-specific way. But that is future music for me.

Modify the script at will (and your own risk ;-)


HTH, Wouter van Reeven

=========================
#!/bin/sh
# Glassfish Startup Script

GLASSFISH_HOME=/usr/local/glassfish; export GLASSFISH_HOME
GLASSFISH_OWNER=glassfish; export GLASSFISH_OWNER

start() {
        echo -n "Starting Glassfish: "
        echo "Starting Glassfish at `date`" >>
$GLASSFISH_HOME/log/start_stop.log
        su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1" >> $GLASSFISH_HOME/log/start_stop.log
        sleep 2
        echo "done"
}
stop() {
        echo -n "Stopping Glassfish: "
        echo "Stopping Glassfish at `date`" >>
$GLASSFISH_HOME/log/start_stop.log
        su $GLASSFISH_OWNER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1" >> $GLASSFISH_HOME/log/start_stop.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
=========================

-- 
People: "If she weighs the same as a Duck, she's made of wood!"
Sir Bedevere: "And therefore...?"