The first solution works well for me as I don't plan on running both
types of servers in production by the time we launch. However, I'm
running into a problem whereby the restart task is calling
restart_solaris and restart_other as expected but both are executing.
For some reason the :except seems to be ignored. Is there some way to
turn on debugging output to figure out what is going on?
On Apr 4, 2:23 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> And, _actually_, there's an even better way to do it. (Why do I
> always think of these things after opening my mouth?)
>
> The problem with the solution I gave you is that the restarts will
> happen serially, instead of in parallel. First, the solaris servers
> will restart, and then the others.
>
> A cleaner way to do it is to package your custom restart code in a
> script that detects the OS on which it is executing and "does the
> right thing." Then, your restart task just needs to call that script,
> and all servers will execute it, choosing the branch that works for
> them, and the restarts occur in parallel again:
>
> task :restart, :roles => :app do
> run "#{current_path}/script/restart"
> end
>
> I'd give the script/restart script here, too, but my shell-fu is
> limited enough that I can't do it off the top of my head. I'll leave
> it as an exercise for the reader. :)
>
> - Jamis
>
> On Apr 4, 2007, at 12:10 PM, maui wrote:
>
>
>
> > Very cool!
>
> > Thank You Jamis
>
> > On Apr 4, 12:51 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> >> On Apr 4, 2007, at 9:03 AM, maui wrote:
>
> >>> Hi everyone,
>
> >>> Over here we're using multiple OSs for our rails app. Our dev
> >>> env is
> >>> on a FreeBSD box and we're using TextDrive Accelerators for
> >>> deployment
> >>> (OpenSolaris). As a result we need to customize a few of our tasks
> >>> based on the server type. One idea we had was to use extra
> >>> information to indicate which servers are running OpenSolaris. For
> >>> example s1.foo.com is running FreeBSD and s1.foo.com is running
> >>> Solaris.
>
> >>> role :app, "s1.foo.com"
> >>> role :app, "s2.foo.com", :solaris => true
>
> >>> So, the question is can a task see which server it is being executed
> >>> on? For instance:
>
> >>> task :restart do
> >>> if <extra information for this server hash>[:solaris]
> >>> run 'svcadm restart /network/mongrel'
> >>> else
> >>> mongrel_rails cluster::restart
> >>> end
> >>> end
>
> >>> Does the magic code in angle brackets above exist?
>
> >> Mark, no, because the task is not executed once for each server, but
> >> once for all matching servers. The "right" way to do that would be to
> >> put the different parts in different tasks, and put the condition on
> >> the task:
>
> >> task :restart do
> >> restart_solaris
> >> restart_other
> >> end
>
> >> task :restart_solaris, :only => { :solaris => true } do
> >> run 'svcadm restart /network/mongrel'
> >> end
>
> >> task :restart_other, :except => { :solaris => true } do
> >> run "mongrel_rails cluster::restart"
> >> end
>
> >> Hope that helps,
>
> >> Jamis
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---