iso_9001_
iso_9001_

Reputation: 2859

glassfish dies and does not start again

One of our application servers (Glassfish v3.0.1) keeps crushing down with no reason. Sometimes, I am away from Internet so I cannot run it back again. Therefore, I wrote a simple bash script to wait for 10 minutes and then run asadmin. It is like:

#!/bin/bash
while true; 
do sleep 600;
sudo /home/ismetb/glassfishv3.0.1/glassfish/bin/asadmin start-domain; 
done

This seems to work fine however I have a couple of problems:

  1. If I terminate the bash script (by pressing ctrl+z buttons), the Java process (Glassfish) dies and start-domain and stop-domain commands do not work at all. That means, I can neither stop Glassfish nor can I access it. I do not know if anybody else experienced this problem before or not. If the process dies, only thing I can do is to look for the ID of Java process and kill it from terminal. This not desirable at all. Any ideas why Java process dies when I quit script?
  2. What I want to add to my script is something like to check the port Glassfish is using. If port is occupied maybe I can assume that Glassfish is not down! (However, the port (8080 default) might still be used by Glassfish although Glassfish is dead, I am not sure of it). If not, then with the help of a simple code, I can get the id of the Java process and kill them all. Then start-domain command will successfully work. Any ideas or any directions on how I can do this?

Upvotes: 2

Views: 1181

Answers (1)

Olaf Dietsche
Olaf Dietsche

Reputation: 74058

You can use a cron job instead. To install a cron job for root, enter

sudo crontab -e

and add this line

*/10 * * * * /home/ismetb/glassfishv3.0.1/glassfish/bin/asadmin start-domain

This will run asadmin every ten minutes.

If you're not comfortable with the command line, you might also try gnome-schedule, but I have no experience with that.

For your second problem, you can use curl or wget to access glassfish. You can try to get some URL, or even access the administration interface, and if you don't get a response, assume glassfish is down.

Upvotes: 2

Related Questions