Hi Jamis,

Thanks for your help!

For now I have just put a sleep statement in capistrano/configuration/
connections.rb after:

        servers.each_slice(max_hosts) do |servers_slice|
          begin
            establish_connections_to(servers_slice)
            sleep 30

That should work for me for now. I am new to ruby, but if I figure out
how to get this to work "properly", I will submit a patch.


Thanks for all your hard work on this project!



On Jun 10, 1:21 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> No worries, it's really my fault for the abysmal lack of  
> documentation. Currently, the source code is the documentation,  
> meaning that if you want to know what options are available, you have  
> to go spelunking through the code. :(
>
> Regarding a wait time for max_hosts, do you mean, a delay before the  
> next set of hosts is used? There is currently no delay between runs,  
> but that might make a good patch. The code in question is in  
> capistrano/configuration/connections.rb, just search for :max_hosts.
>
> - Jamis
>
> On Jun 10, 2008, at 1:24 PM, JasonSmithy wrote:
>
>
>
> > Thank you Jamis!
>
> > Please forgive my ignorance, but how can I know what other options
> > like :max_hosts are available? And is there a way to configure the
> > time that max_hosts waits? I have not had any luck finding it in the
> > source yet.
>
> > Thanks again!
>
> > On Jun 9, 9:16 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> >> Actually, capistrano has that functionality baked in, via  
> >> the :max_hosts
> >> option. You could define your role with a block, so it gets evaluated
> >> late (from a temp file, for example), and then just set  
> >> the :max_hosts
> >> option on the task in question. E.g.:
>
> >>   role :dynamic_servers do
> >>     IO.readlines(server_list).map { |line| line.chomp }
> >>   end
>
> >>   desc "Test cycling through servers"
> >>   task :test_each, :roles => :dynamic_servers, :max_hosts => 5 do
> >>     run "uptime"
> >>   end
>
> >> Then, when capistrano is asked to execute the "uptime" command on all
> >> servers in the dynamic_servers role, it will first evaluate the block
> >> for the dynamic_servers role, and will then see that it is only to  
> >> use 5
> >> hosts at a time.
>
> >> - Jamis
>
> >> JasonSmithy wrote:
> >>> Hi,
>
> >>> Is there anyway to reset a role?
>
> >>> What I want to do is read a list of IPs dynamically from a temporary
> >>> file, then run a task on a portion of the list at a time, not have  
> >>> the
> >>> task run on all the IP's directly in parallel. What I am trying to  
> >>> do
> >>> so far is to get the list, run the task on the first IP in the list,
> >>> sleep for 5 seconds and then run the task again on the next IP in  
> >>> the
> >>> list. Ideally, this would take 5 IPs at a time until all IPs are
> >>> executed, but I need to learn to crawl before I can walk ;)
>
> >>> task :test_cycle do
> >>>    transaction do
> >>>            set :j, 4
> >>>            set :k, 0
> >>>            $servers = IO.readlines(server_list)    # Get the list  
> >>> of servers from
> >>> temp file.
> >>>            while k < j
> >>>                            # This is a method to increment by one.  
> >>> Capistrano
> >>>                            # complains that "+" is an unknown  
> >>> method without this.
> >>>                def add(value)
> >>>                    value = value + 1
> >>>                    return value
> >>>                end
>
> >>>                $ip = $servers[k].chomp
>
> >>>                             role :servers_each, $ip                
> >>> # Set the
> >>> server_each role to the new IP
>
> >>>                             test_each                      # Run  
> >>> the task
> >>>                    set :k, add(k)                  # Increment k  
> >>> by 1.
> >>>                             role :servers_each, servers_each.clear
> >>>                        end
> >>>             end
> >>> end
>
> >>> desc "Test cycling through servers"
> >>> task :test_each, :roles => :servers_each do
> >>>    run "uptime"
> >>>    puts "Sleeping for 5 seconds"
> >>>    sleep 5
> >>> end
>
> >>> This works except for each time the loop is run, the next IP gets
> >>> added to the server_each role. This has the effect of re-running the
> >>> command on each server each time. So the first time it runs from 1
> >>> server. The next time, it runs on 2 servers, and so on.
>
> >>> How can I set server_each back to empty after running test_each  
> >>> and is
> >>> this even the a good way to do this?
>
> >>> Thanks in advance for you help!
--~--~---------~--~----~------------~-------~--~----~
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