[Linux-HA] Tomcat times out

Michael Alger linux-ha at mm.quex.org
Mon Jul 7 03:57:53 MDT 2008


On Mon, Jul 07, 2008 at 11:40:06AM +0200, Ehlers, Kolja wrote:
> 
> I have a general question about bash programming since yet I am
> not too familiar with it. The isrunning_tomcat() function in the
> tomcat ocf keeps returning an error code. This is the function:
> 
> 	if wget -O /dev/null $RESOURCE_STATUSURL 2>/dev/null; then
> 		return $OCF_SUCCESS
> 	fi
> 	return $OCF_ERR_GENERIC
> 
> The problem is the if condition keeps returning false. I just dont
> get this part:
> 
> wget -O /dev/null $RESOURCE_STATUSURL 2>/dev/null;
> 
> What does especially the 2 mean? I know that wget tries to connect
> to the statusurl, but the wget responds is directed to dev/null so
> how can this be true or false?

The 2> part is redirecting file descriptor 2 (stderr) to /dev/null,
which hides the status messages as well as any error messages.
The actual file download is output to /dev/null as well (via -O).

The return code is whatever wget exit()s to the system with. You can
look at it in the shell with $?.

e.g.

  $ true ; echo $?
  0
  $ false ; echo $?
  1

So to test wget, you can work out what $RESOURCE_STATUSURL is,
and then run:

wget -O /dev/null http://whatever/the/status/url/is.jsp
echo $?

The 'echo $?' should output 0 if the service is available. Anything
else will be evaluated as "false".


More information about the Linux-HA mailing list