All set. Just wanted to document this in case anybody else has the same 
question. 

I was not able to get it to work with :once => true at the task level, but it 
was pretty simple to set up with roles.

role :shared_content_owner, "master.rob.by"

 task :update_code, :except => { :no_release => true }, :roles => 
[:shared_content_owner] do
 run "echo 'here!'"
 on_rollback { run "rm -rf #{release_path}; true" }
 strategy.deploy!
 finalize_update
 end


Output is what you'd expect:

 * executing `deploy:update_code'
 * executing "echo 'here!'"
 servers: ["master.rob.by"]
 [master.rob.by] executing command
** [out :: master.rob.by] here!
 command finished in 1101ms

Thanks again, Lee.

-- 
Robby Grossman
@freerobby (http://twitter.com/freerobby)
http://rob.by (http://rob.by/)


On Thursday, September 1, 2011 at 12:25 PM, Robby Grossman wrote:

>  Thanks, Lee. 
> 
> I think I'm on the right track but I'm missing something. I did as you said, 
> modifying my update_code as follows (bold change mine):
> 
>  task :update_code, :except => { :no_release => true }, :once => true do
>  run "echo 'here!'"
>  on_rollback { run "rm -rf #{release_path}; true" }
>  strategy.deploy!
>  finalize_update
>  end
> 
> 
> However when I run a "cap deploy:update_code", it still seems to run on both 
> servers:
> $ cap deploy:update_code app=blog_shareaholic
>  * executing `deploy:update_code'
>  * executing "echo 'here!'"
>  servers: ["master.rob.by", "slave.rob.by"]
>  [slave.rob.by] executing command
>  [master.rob.by] executing command
> ** [out :: slave.rob.by] here!
> ** [out :: master.rob.by] here!
>  command finished in 546ms
> 
> I'm a little puzzled because I checked the commenting docs in invocation.rb, 
> and it confirms what you said:
>  # * :once - if true, only the first matching server will be selected. The 
> default
>  #  is false (all matching servers will be selected).
> 
> Just wondering if there's something obvious I've done wrong? I'm using 
> capistrano v2.8.0.
> 
> Thanks again,
> Robby
> 
> -- 
> Robby Grossman
> @freerobby (http://twitter.com/freerobby)
> http://rob.by (http://rob.by/)
> 
> 
> On Thursday, September 1, 2011 at 12:19 PM, Robby Grossman wrote:
> 
> >  Thanks, Lee. 
> > 
> > One quick follow-up:
> > 
> > Is there any way to do this at the actual task level, i.e. change deploy.rb 
> > to read (bold mine):
> > 
> >  task :update_code, :once => true, :except => { :no_release => true } do
> >  on_rollback { run "rm -rf #{release_path}; true" }
> >  strategy.deploy!
> >  finalize_update
> >  end
> > 
> > 
> > The actual "run" commands, where I've seen :once => true used are buried
> > -- 
> > Robby Grossman
> > @freerobby (http://twitter.com/freerobby)
> > http://rob.by (http://rob.by/)
> > 
> > 
> > On Thursday, September 1, 2011 at 5:54 AM, Lee Hambley wrote:
> > 
> > > Robby,
> > > 
> > > There's no way to do this from the outside, you'd have to modify the 
> > > :update_code task to run with the :once => true argument. This isn't such 
> > > a big deal, simply take the deploy.rb out of the gem, and drop it in your 
> > > project (and update the require/load in your Capfile accordingly), this 
> > > is a pretty sane way to work anyway (and insulates you from surprise 
> > > upstream changes which might break your deploy.) 
> > > 
> > > - Lee
> > >  -- 
> > >  * You received this message because you are subscribed to the Google 
> > > Groups "Capistrano" group.
> > >  * To post to this group, send email to [email protected] 
> > > (mailto:[email protected])
> > >  * To unsubscribe from this group, send email to 
> > > [email protected] 
> > > (mailto:[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