I solved this issue in a different way but I'm not sure our use cases are the same. My issue was that I had a long chain of setup tasks that I wanted to execute with deploy:setup. The downside of doing this was that if I wanted to execute just one of those tasks it would end up starting whole chain of events... Which I most certainly did not want.
What I decided to do is put the task chain in an on :start, :only => ["deploy","deploy:cold","deploy:setup","deploy:migrations"] do block. So if I'm doing a top level deploy task all of my before and afters are hooked in, but if I'm not doing a top level deploy task, all of my tasks run unfettered from each other. On May 12, 2009, at 7:19 AM, Jamis Buck <[email protected]> wrote: > > Looks like the documentation is ambiguous. What it means is, that > particular version of the method doesn't invoke the callbacks. > However, > Capistrano also loads the "Callbacks" module (capistrano/ > callbacks.rb), > which overrides the invoke_task_directly method to decorate it with > the > callback calls. > > So, you have two options. > > First, you can call the task via > "invoke_task_directly_without_callbacks" (which is what the original > method is aliased to when the callbacks are added). > > Second (and this option is cleaner, I think, but only works when you > have control over the tasks being invoked): write the target task as a > vanilla Ruby method, first, and then have the tasks call the method. > E.g. > > > def do_foo > puts "foo!" > end > > task :say_foo_without_bar do > do_foo > end > > task :say_foo do > do_foo > end > > task :say_bar do > puts "bar!" > end > > after :say_foo, :say_bar > > It takes a little more planning, but it's less magical, and less > dependent on internal Capistrano methods. > > - Jamis > > On 5/12/09 8:02 AM, Emily wrote: >> I'm working on a complex Capistrano recipe that requires being able >> to >> run a task without callbacks. After some searching through source and >> rdocs, it seems that "execute_task" is the intended way to do this. >> The documentation states that it "executes the task with the given >> name, without invoking any associated callbacks." However, when I run >> a task with execute_task, its callbacks are executed. I also tried >> using invoke_task_directly, which is what execute_task calls >> internally, and that also runs callbacks. Am I misunderstanding the >> purpose of execute_task? Is there some other method I should be >> using? >> I'm including a minimal Capfile which demonstrates the problem I'm >> having along with the results I'm getting and the results I'm >> expecting. >> >> I've spend a little bit of time trying to figure out what's happening >> with this in the ruby debugger, but with all the meta-programming >> going on in Capistrano, I had a hard time figuring out what's >> actually >> happening. So I thought that before I spend a whole day digging >> through the source code, I'd see if perhaps anyone else had >> experienced something similar or if I was misinterpreting what >> execute_task is supposed to do. >> >> Thanks in advance for your help, >> - Emily >> >> The capfile: >> task :say_foo_without_callback do >> t = top.find_task 'say_foo' >> execute_task t >> end >> >> task :say_foo do >> puts 'foo!' >> end >> >> task :say_bar do >> puts 'bar!' >> end >> >> after :say_foo, :say_bar >> >> >> Output from 'cap say_foo': >> * executing `say_foo' >> foo! >> triggering after callbacks for `say_foo' >> * executing `say_bar' >> bar! >> >> >> Output from 'cap say_foo_without_callback': >> * executing `say_foo_without_callback' >> * executing `say_foo' >> foo! >> triggering after callbacks for `say_foo' >> * executing `say_bar' >> bar! >> >> >> What I would expect from 'cap say_foo_without_callback': >> * executing `say_foo_without_callback' >> * executing `say_foo' >> foo! >> >>> > > > --~--~---------~--~----~------------~-------~--~----~ To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/capistrano -~----------~----~----~----~------~----~------~--~---
