It's ruby so putting inside a task is also valid if you understand the implications

Inside a task you are saying that only when I use this task do I want this behavior to occur. Which also leads to a cart ahead of the horse problem

In your first example if you do

Cap deploy:setup

The before call is never run

Cap deploy:setup deploy:run_all

The before call is run too late, deploy:setup has already started

In your second example run_all is redundant

Cap deploy:run_all

Would do the same as

Cap deploy:setup

The simplest thing you could do is

task :run_all. :roles => some_role do
 setup
   one
   two
   three
end


Then

Cap deploy:run_all

Will run setup,1,2,3

But

cap deploy:setup

Only does setup


On Mar 4, 2010, at 7:30 AM, pete <[email protected]> wrote:

Does the before statement live outside of a task?  Can it be
considered a rule?  When I tried to chain the commands as you have
below, they didn't get executed.

For example, I have a task such as this:

task :run_all. :roles => some_role do
before "deploy:setup",
  "deploy:one",
  "deploy:two",
  "deploy:three"
end

If I call the "run_all" task, will this initiate the chain to start
executing? That didn't work for me.

Or, should this really be like this:

before "deploy:setup",
  "deploy:one",
  "deploy:two",
  "deploy:three"

task :run_all. :roles => some_role do
 setup
end

So, the before statement lives outside of the task, and all we do is
initiate the "setup" task which will trigger the other events to
occur.

Thanks for the feedback!





On Mar 3, 5:56 pm, Donovan Bray <[email protected]> wrote:
you can do

before "deploy:setup", "deploy:one", "deploy:two", "deploy:three"

I usually format them as:

before "deploy:setup",
  "deploy:one",
  "deploy:two",
  "deploy:three"

Which is clearer to me

you can also do it as a block and method call syntax

before "deploy:setup" do
  deploy.one
  deploy.two
  deploy.three
end

There is also a way to do transactions, such that rollbacks are called if one of the tasks fails. I haven't had an opportunity to use the transaction
form, but it exists.

I also wrap my top level tasks so that long task chains don't get invoked
unless I use a top level task

on :start, :only => ["deploy:setup", "deploy:cold", "deploy",
"deploy:migrations"] do
  after "deploy:migrate", "notify:admins"
end

That allows me to run "deploy:migrate" by itself without triggering behavior that should happen with the top level tasks. This is particularly helpful
when you are trying to fix something that has went wrong.

Many of my recipes have common commands, like :install, :setup, :configure, :verify where: after "sphinx:install", "sphinx:setup", "sphinx:configure",
"sphinx:verify"

When "sphinx:install" is called in a top level task, it automatically
follows up with the other three.

But when I invoke without one of the top level tasks, I can call them
individually and it doesn't start walking down the task chain.



On Wed, Mar 3, 2010 at 1:36 PM, pete <[email protected]> wrote:
Hi-

I would like to execute several commands that each depend on each
other.  For example, "cleanup" depends on "deploy" completing and
"deploy" depends on "stage" completing.

I have separate tasks defined for each of these, but when I try to add
them into a single task to run them all, sometimes files don't exist
when deploying because "stage" did not finish executing, etc.

Seems like an ideal situation for "before" but all the examples I have seen only show "before" being used with 2 tasks (e.g. before ("task2",
"task1")

Is there a way to chain multiple events that have dependencies on each
other using the "before" task?

Thanks!

--
* You received this message because you are subscribed to the Google Groups
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to
[email protected]<capistrano %2bunsubscr...@googlegrou ps.com>For more options, visit this group at
http://groups.google.com/group/capistrano?hl=en

--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/capistrano?hl=en

--
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to 
[email protected] For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to