I have a Rails 3 app deployed on Appfog with a postgresql database. I would like to run background jobs with IronWorker but i can not connect to my database.
Here are my ironworker files (.worker + my_worker.rb)
.worker
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
Then i create a task, with passing the database connection to ironworker:
client = IronWorkerNG::Client.new
client.tasks.create("my_worker", database:Rails.configuration.database_configuration[Rails.env])
And here is the error i have in 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?
Can somebody help me out to connect my Appfog DB from IronWorker ?
Thanks a lot in advance
-- Mathieu
As far as i know, AppFog blocking external connections to their databases https://groups.google.com/forum/?fromgroups=#!topic/appfog-users/I31ni0pff9I
Possible solutions: