Thanks, I will need to look into wget's retry logic and all the relevant parameters. It will certainly make things a lot cleaner.
I don't understand why you suggest not to fail with exit 1. The task has failed. The plan is that I want to later on implement rollback logic and then I need the task to fail to trigger the rollback logic. I am also unsure about where you meant me to put the [puts "fail"] statement. Surely it must be in a if statement of some sorts otherwise it would just print fail regardless of whether it worked or not. Regards On Jan 22, 3:30 pm, Mike Bailey <[email protected]> wrote: > 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 --quiethttp://localhost:8080/;then echo 'success'; else echo > 'fail'; fi; > fail > maculike2:~ mbailey$ if wget --tries=1 --wait=1 --connect-timeout=1 > --timeout=1 --quiethttp://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 -~----------~----~----~----~------~----~------~--~---
