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

Reply via email to