Yikes.
The cleanest way to do that is to write a shell script, which does
the case statement. Then you can just do:
run "script/my_custom_mongrel_runner"
Alternatively, you can have one script per server, and let Capistrano
determine which one to run using the host placeholder:
run "script/mongrel_runner_$CAPISTRANO:HOST$"
- Jamis
On Jun 14, 2007, at 4:16 AM, hemant wrote:
>
> Jamis,
>
> Ok I understand you partially, but is there only one way of doing
> this:
>
> task :custom_deploy,:roles => :app do
> update_code
> symlink
> configure_mongrel_conf12
> end
>
> task :configure_mongrel_conf12, :roles => :app do
> mongrel_command =<<-DESC
> case `echo $HOSTNAME` in
> "xaos") sudo mongrel_rails cluster::restart -C
> "#{current_path}/extra_configs/local_cluster.yml";;
> "ubuntu") sudo mongrel_rails cluster::restart -C
> "#{current_path}/extra_configs/mongrel_cluster.yml";;
> esac
> DESC
> run mongrel_command do |channel,stream,data|
> channel.send_data("password\n")
> end
> end
>
>
>
>
> On 6/14/07, Jamis Buck <[EMAIL PROTECTED]> wrote:
>>
>> There's not really a special syntax for delayed evaluation of roles,
>> but you can programmatically set roles in tasks:
>>
>> task :set_roles do
>> servers = something_that_returns_an_array_of_server_names
>> role :app, *servers
>> end
>>
>> Note that because a task is run for all matching servers in parallel,
>> the question "can I query what server the task is being run on right
>> now" doesn't really make sense. However, if you need to substitute
>> the server name in a command, you can do (e.g.):
>>
>> run "echo $CAPISTRANO:HOST$"
>>
>> That would echo the name of the current host to the screen. That only
>> works inside of the command that you pass to run or sudo, though,
>> because run/sudo substitute that placeholder text with the server
>> name immediately before sending the command to the corresponding
>> server.
>>
>> If you want to run a command on only a single host at a time, you can
>> pass the :hosts key to run/sudo:
>>
>> run "this is on foo.bar.com", :hosts => "foo.bar.com"
>> run "this is on baz.bang.com", :hosts => "baz.bang.com"
>>
>> Note that you lose the parallelization this way, since the first run
>> must finish before the second one can start. That may not matter
>> to you.
>>
>> - Jamis
>>
>> On Jun 13, 2007, at 3:59 PM, hemant wrote:
>>
>>>
>>> Hi,
>>>
>>> Basically for some of my deployment machines, I have entirely
>>> different mongrel_cluster.conf and for rest of them its the same.
>>>
>>> So basically when cap is using mongrel_cluster.conf to restart my
>>> mongrels on those machines, I want cap to pick different cluster
>>> config file.
>>>
>>> Plain vanilla setup has:
>>>
>>> set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
>>>
>>> So on every machine, it would look for mongrel_cluster.yml file.
>>> Now,
>>> for some machines I want cap to use
>>> #{current_path}/config/mongrel_cluster_www4.yml.
>>>
>>> I saw delayed evaluation of variables, but wasn't sure, how can i
>>> turn
>>> that facility to my evil purposes.
>>>
>>> Also, if somehow within a task,
>>>
>>> task :restart, :roles => :app do
>>> # app was an array, and If I can get for which machine currently
>>> this task is executed
>>> # then I should be able to pull this trick.
>>> end
>>>
>>>
>>> --
>>> gnufied
>>> -----------
>>> There was only one Road; that it was like a great river: its springs
>>> were at every doorstep, and every path was its tributary.
>>> http://people.inxsasia.com/hemant
>>>
>>>>
>>
>>
>>>
>>
>
>
> --
> gnufied
> -----------
> There was only one Road; that it was like a great river: its springs
> were at every doorstep, and every path was its tributary.
> http://people.inxsasia.com/hemant
>
> >
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---