我有一个带有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 DB吗?
非常感谢
- Mathieu
据我所知,appfog阻止外部连接到其数据库https://groups.google.com/forum/?fromgroups=# !! topic/appfog-users/i31ni0pff9i
可能的解决方案:
- oke appfog
- 切换到其他数据库hoster
- 做某种隧道。例如,Ironworker平台允许您在工人执行期间与任何非特权代码进行交互,因此您可以尝试将SSH隧道设置为"好"机器。