Thanks
Rather logical in retrospec :-) ... it works well now.

Slowly but surely I am getting there.

Regards

On Feb 20, 4:37 pm, Jamis Buck <[email protected]> wrote:
> If an exception is raised, it does not cause a task to return a value;
> it causes a task to raise an exception. You need to use a begin/rescue
> clause, instead of an unless condition.
>
>   begin
>     some.task
>   rescue Exception => e
>     puts "got exception: #{e}"
>   end
>
> Does that make sense? Exceptions bypass your program logic and require
> explicit handling.
>
> - Jamis
>
> On 2/20/09 9:28 AM, Gerhardus Geldenhuis wrote:
>
> > Hi
> > Version 1
> >   task :check_lb_worker_exists, :roles => :apacluster, :on_error
> > => :abort do
> >     if exists?(:modjk_loadbalancerworker) then
> >       begin
> >         run "if wget #{wgetparams} 'http://$CAPISTRANO:HOST$/jkserver-
> > status?cmd=edit&from=list&w=#{modjk_loadbalancerworker}' | grep
> > 'ERROR'; then false;else true;fi  2>&2>/dev/null;"
> >       rescue
> >         puts "The specified modjk load balancer worker does not
> > exists"
> >       end
> >     end
> >   end#task
>
> > calling the task:
> > task :preflightcheck, :on_error => :abort do
> >   unless exists?(:app_path)
> >     abort "The download path variable app_path has not been specified"
> >   end
>
> >   modjk.check_lb_worker_exists
>
> >   puts 'Everything is fine'
> > end
>
> > This version works fine except that everything is always fine
> > "regardless whether the check_lb_worker_exists failed or not
>
> > version 2
> > ~~~~~~~
>
> >   task :check_lb_worker_exists, :roles => :apacluster, :on_error
> > => :abort do
> >     if exists?(:modjk_loadbalancerworker) then
> >         run "if wget #{wgetparams} 'http://$CAPISTRANO:HOST$/jkserver-
> > status?cmd=edit&from=list&w=#{modjk_loadbalancerworker}' | grep
> > 'ERROR'; then false;else true;fi  ;"
> >     end
> >   end#task
>
> > task :preflightcheck, :on_error => :abort do
> >   unless exists?(:app_path)
> >     abort "The download path variable app_path has not been specified"
> >   end
>
> >   unless not modjk.check_lb_worker_exists
>
> >     abort 'horribly broken'
> >   end
>
> >   puts 'all looks fine!'
> > end
>
> > In version two if the check_lb_worker task fails that failure does not
> > get handled by the unless abort block in the main preflight check.
>
> > Basically I am trying to do the following:
>
> > task preflight
> >   unless run(some command) fail
> >   unless run_task_check1, fail with nice message
> >   unless run_task_check2, fail with nice message
>
> >   if nothing failed then put "everything looks ok"
> > end
>
> > I am struggling to get the final "everything looks ok" message to
> > display only if everything really is ok because at the moment it
> > displays regardless. I hope this is all making some kind of sense...
> > otherwise I will have to try again.
>
> > 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