I've managed to set up my workers and they used to execute without issue (in development) but now they don't in either production or development (I'm guessing after changing from SQlite3 to PostgreSQL).
When I run a rake command to run the workers with rake resque:work QUEUE=*
I get the following error and stack trace:
getaddrinfo: nodename nor servname provided, or not known
I get the following errors when running heroku rake resque:work QUEUE=*
in the console to test pending workers in the queue.
Class SentimentJob
Arguments [4, 5, 6]
Exception ActiveRecord::StatementInvalid
Error PGError: server closed the connection unexpectedly This probably means
the server terminated abnormally before or while processing the request.
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc,
a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid =
d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"taggings"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum
And for my Facebook worker:
Class FBConnectionsJob
Arguments 1
Exception OpenSSL::SSL::SSLError
Error SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B:
certificate verify failed
Class FBConnectionsJob
Arguments 1
Exception ActiveRecord::StatementInvalid
Error PGError: server closed the connection unexpectedly This probably means
the server terminated abnormally before or while processing the request.
: SELECT tablename FROM pg_tables WHERE schemaname = ANY
(current_schemas(false))
Why do I get different errors in different environments? My initializer files look like:
Should I add ENV specifications here?
Resque.rb
uri = URI.parse(ENV["REDISTOGO_URL"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file }
Redis.rb
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Resque.redis = REDIS
My environments/production.rb file has no reference to Redis and my environments/development.rb file has this for Redis setup:
ENV["REDISTOGO_URL"] = 'redis://username:[email protected]:6789'
Adding the following to my Rakefile fixed a similar problem for me:
task "resque:setup" => :environment do
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
end
This reconnects PostgreSQL before Resque forks its process to create a worker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With