I did a patch to support :once on the task; natively cap only supports :once on 
the 'run' and 'sudo' helpers. 

Try 

> run "echo 'here!'", :once => true

And I'll look for my patch tomorrow. 

On Sep 1, 2011, at 9:25 AM, Robby Grossman <[email protected]> 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://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://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]
>>> * 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

-- 
* 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