簡體   English   中英

Appfog + Rails 3 + Postgresql + IronWorker =>無法連接到服務器:連接超時(PG :: Error)

[英]Appfog + Rails 3 + Postgresql + IronWorker => could not connect to server: Connection timed out (PG::Error)

我有一個Postgresql數據庫在Appfog上部署了Rails 3應用程序。 我想使用IronWorker運行后台作業,但無法連接到數據庫。

這是我的Ironworker文件(.worker + my_worker.rb)

。工人

runtime "ruby"
gemfile '../Gemfile'
dir "../app/models" # merge all models
full_remote_build true
exec "my_worker.rb"

my_worker.rb

require 'rubygems'
require 'active_record'
require 'pg'
require 'models/my_model.rb'


def setup_database
  puts "Database connection details:#{params['database'].inspect}"
  return unless params['database']
  # estabilsh database connection
  ActiveRecord::Base.establish_connection(params['database'])
end


setup_database
@my_models = My_model.all

然后,我創建一個任務,並將數據庫連接傳遞給ironworker:

client = IronWorkerNG::Client.new
client.tasks.create("my_worker", database:Rails.configuration.database_configuration[Rails.env])

這是我在IronWorker中遇到的錯誤

/task/__gems__/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `initialize': could not connect to server: Connection timed out (PG::Error)
Is the server running on host "10.0.48.220" and accepting TCP/IP connections on port 5432?

有人可以幫我從IronWorker連接我的Appfog數據庫嗎?

在此先多謝

-Mathieu

據我所知,AppFog阻止了與其數據庫的外部連接https://groups.google.com/forum/?fromgroups=#!topic/appfog-users/I31ni0pff9I

可能的解決方案:

  • 戳AppFog
  • 切換到其他數據庫托管人
  • 做一些隧道。 例如,IronWorker平台允許您在worker執行期間與任何非特權代碼進行交互,因此您可以嘗試將SSH隧道設置為“好”機器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM