Always exit with 0. Errors are ugly. Just "puts 'fail'" instead.

You can put the retry logic into the wget command.

- Mike

maculike2:~ mbailey$ if wget --tries=1 --wait=1 --connect-timeout=1
--timeout=1 --quiet http://localhost:8080/; then echo 'success'; else echo
'fail'; fi;
fail
maculike2:~ mbailey$ if wget --tries=1 --wait=1 --connect-timeout=1
--timeout=1 --quiet http://www.google.com/; then echo 'success'; else echo
'fail'; fi;
success


On Fri, Jan 23, 2009 at 2:13 AM, Gerhardus Geldenhuis <
[email protected]> wrote:

>
> Hi
> I have written the following script to monitor succesfull startup of
> our webapp:
> I am trying every second to get a webpage but also have a timeout
> which will fail the task after 60 seconds.
>
> task :monitor_app_startup, :roles => :testct do
>  run <<-CMD
>    for ((n=0; n<61; n++ )); do
>      if wget localhost:8080/gta/buildInfo.jsp --quiet -O - --connect-
> timeout=1 --timeout=1 --tries=1 | grep -q "Build Information"; then
> exit 0
>      elif [ $n -eq 60 ]; then exit 1;
>      fi;
>      sleep 1;
>    done
>  CMD
> end
>
> I would appreciate any feedback or suggestions to improve this or do
> it differently.
>
> Also if the task fails the error message looks something like this:
>
> failed: "sh -c \"for ((n=0; n<61; n++ )); do\\\\\n      if wget
> localhost:8080/gta/buildInfo.jsp --quiet -O - --connect-timeout=1 --
> timeout=1 --tries=1 | grep -q \\\"Build rrInformation\\\"; then exit
> 0;\\\\\n      elif [ \\$n -eq 5 ]; then exit 1;\\\\\n      fi;\\\\
> \n      sleep 1;\\\\\n    done\"" on longtct03g
> [
>
> which is very ugly. Is there a way to override the failure message for
> a task?
>
> Regards
> >
>

--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to