2013-05-02 20 views
0

我正在嘗試使用Amazon Opsworks獲得與Postgres一起使用的基本rails應用程序。 Opsworks目前缺少對Postgres的內置支持,但是我使用了一些我發現的寫得很好的烹飪書。我已經把它們全部分配給了我的自定義食譜:https://github.com/tibbon/custom-opsworks-cookbooks在Amazon Opsworks中使用Postgresql - 在database.yml中獲取IP地址

無論如何,我現在卡在主要postgres數據庫的ip地址到database.yml文件中。它似乎,應該有多個後端指定,有點像我的haproxy服務器如何看到所有的軌道服務器'後端'。

有沒有人得到這個工作?

回答

4

我不得不添加一些自定義的JSON到我的Rails圖層。

是這樣的:

{ 
    "deploy": { 
    "my-app-name": { 
     "database": { 
     "adapter":"mysql2", 
     "host":"xxx.xx.xxx.xx" 
     } 
    } 
    } 
} 
1

我相信你必須定義更新的database.yml並重新啓動應用程序服務器的自定義配方。

this guide同樣的事情,使用Redis的服務器爲例進行:

node[:deploy].each do |application, deploy| 
    if deploy[:application_type] != 'rails' 
    Chef::Log.debug("Skipping redis::configure as application #{application} as it is not an Rails app") 
    next 
    end 

    execute "restart Rails app #{application}" do 
    cwd deploy[:current_path] 
    command "touch tmp/restart.txt" 
    action :nothing 
    only_if do 
     File.exists?(deploy[:current_path]) 
    end 
    end 

    redis_server = node[:opsworks][:layers][:redis][:instances].keys.first rescue nil 

    template "#{deploy[:deploy_to]}/current/config/redis.yml" do 
    source "redis.yml.erb" 
    mode "0660" 
    group deploy[:group] 
    owner deploy[:user] 
    variables(:host => (node[:opsworks][:layers][:redis][:instances][redis_server][:private_dns_name] rescue nil)) 
    notifies :run, resources(:execute => "restart Rails app #{application}") 

    only_if do 
     File.directory?("#{deploy[:deploy_to]}/current") 
    end 
    end 
end 

我沒有爲自己測試了這個,但是我相信我會很快,我會嘗試更新這個答案我很快就做到了。