我在 Appfog 上部署了一个带有 postgresql 数据库的 Rails 3 应用程序。我想用 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 DB 吗?
非常感谢提前
——马修