This is a discussion on How to Run GlassFish V3 as a Service on Linux Ubuntu/Debian - Solaris Rss ; We already support running GlassFish V3 as a service on Solaris 10 and Windows platforms (see my blog ). I have been investigating how to provide support for automatically starting GlassFish V3 as a service on Linux. Of course before ...
We already support running GlassFish V3 as a service on Solaris 10 and Windows platforms (see my blog). I have been investigating how to provide support for automatically starting GlassFish V3 as a service on Linux. Of course before I can hope to do that -- I must be able to set it up manually. In this blog I will take you through the manual steps needed to run GlassFish V3 as a service on Linux.
This procedure was worked out on my Linux system which happens to be Ubuntu. Other flavors of Linux may have slightly different procedures.
One decision you need to make right up front is what Linux user should "own" GlassFish V3. Typically root is used as the owner. If you choose root as the user you get the advantage that you can use ports < 1024 without complex configuration changes to the system. For this blog I used root.
Here are the steps -- the file named "glassfish" in step 4 is the simple init script which appears at the end of this blog.
- Install JDK 6 if needed
- Have root install GlassFish like so:
- cd /opt
- wget http://download.java.net/glassfish/v...assfish-v3.zip
- unzip glassfish-v3.zip
- rm glassfish-v3.zip
- cd /etc/init.d
- cp glassfish .
- update-rc.d glassfish defaults
- OPTIONAL /etc/init.d/glassfish start
- OPTIONAL Make sure GlassFish is running OK
- reboot -- you are done!
To start, stop, restart GlassFish simply run these commands:
sudo /etc/init.d/glassfish start
sudo /etc/init.d/glassfish stop
sudo /etc/init.d/glassfish restart
# glassfish init script for Linux
# Simplest possible case -- no password file, one default domain
# it would be simple to add such options
case "$1" in
$GLASSFISH_HOME/bin/asadmin start-domain >/dev/null
$GLASSFISH_HOME/bin/asadmin stop-domain >/dev/null
$GLASSFISH_HOME/bin/asadmin restart-domain >/dev/null
echo "usage: $0 (start|stop|restart|help)"