Shell Script to Start and Stop JBoss

I was looking for a script to start and stop JBoss server on the Linux environment, but didn’t find anything that useful. I did find one for starting and stopping lighttpd server for our Rails applications and have been using it effectively. Even though I am not a shell script expert, I thought I will modify the script a bit and make use of it for JBoss. The main change that I had to make was to make the script wait until the server starts or stops. To make sure the server has successfully started, I had to tail the log file for one line until the last line contained the text “JBoss (MX MicroKernel) …….. Started”. To make sure the server stopped successfully I had to ensure the process was terminated completely. If you are in need of such a script, here it is.

Download JBoss start/stop Script

Some items you have to change in the script to work for your environment.

  • PIDFILE - File containing the process id. Change it to a location where you want to have this file.
  • STARTJBOSS - Command to start JBoss. Scan through this command in entire and make sure you have added the parameters necessary for your environment, set the minimum and maximum JVM heap, and also the server you want to start. You can get this information from the server log when you run JBoss using the run.sh script. The script assumes you have Java executable in the path.
  • LOGFILE - The server’s log file. Change it to a location where you want to have this file.

Additionally you might want to change line 32 to the right version of JBoss you are using. Make sure this line reflects exactly what you see in the server log at the end when JBoss completes starting the server. If it doesn’t match, this script will go in infinite loop.

An additional benefit I got after writing this script was to have our automated build scripts using Ant to deploy the applications on any box using the SSHExec tasks. Really cool and time saving.

Disclaimer - The script herein provided to you is “AS IS” without any warranties of any kind. The script has not been thoroughly tested under all conditions. I, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

Blink this Shell Script to Start and Stop JBoss at blinklist.com    Bookmark Shell Script to Start and Stop JBoss at blogmarks    Bookmark Shell Script to Start and Stop JBoss at del.icio.us    Digg Shell Script to Start and Stop JBoss at Digg.com    Fark Shell Script to Start and Stop JBoss at Fark.com    Bookmark Shell Script to Start and Stop JBoss at Furl.net    Bookmark Shell Script to Start and Stop JBoss at NewsVine    Bookmark Shell Script to Start and Stop JBoss at reddit.com    Bookmark Shell Script to Start and Stop JBoss at Simpy.com    Bookmark Shell Script to Start and Stop JBoss at Spurl.net    Bookmark Shell Script to Start and Stop JBoss with wists    Bookmark Shell Script to Start and Stop JBoss at YahooMyWeb

      Cosmos

2 Comments »

  1. Lakshmi Narasimhan Said,

    April 26, 2008 @ 5:24 pm

    Hi,

    Isn’t run.sh supposed to do this? in the bin directory, run.sh in all versions of unix and run.bat in windows will start JBOSS server.

  2. Ramesh Said,

    May 29, 2008 @ 3:22 am

    Hi Lakshmi,
    Yes run.sh/run.bat will help start JBoss, the only disadvantage is that you can leave it to run the process or run it in background. If you are running it directly you cannot close the terminal or the window, because that would kill the JBoss process as well. If you run it as a background, to stop the server you have to find out the PID and then kill it. I find this difficult especially when I run multiple instances of JBoss for different applications on the same box.
    Hope it helps.
    Ramesh

RSS feed for comments on this post · TrackBack URI

Leave a Comment

authimage


Creative Commons License  This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.