0

我在 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 吗?

非常感谢提前

——马修

4

1 回答 1

1

据我所知,AppFog 阻止了与其数据库的外部连接 https://groups.google.com/forum/?fromgroups=#!topic/appfog-users/I31ni0pff9I

可能的解决方案:

  • 戳 AppFog
  • 切换到其他数据库主机
  • Make some kind of tunnel. As example, IronWorker platform allows you to interact with any non-privileged code during worker's execution, so you can try to set up SSH tunnel to 'good' machine.
于 2012-12-22T19:52:58.213 回答