我已经成功设置了我的工作进程,并且它们在开发环境中能够正常执行,但现在无论是生产环境还是开发环境都不能执行(我猜测是从 SQlite3 切换到 PostgreSQL 后出现的问题)。
当我运行 rake 命令以rake resque:work QUEUE=*
来运行工作进程时,我会得到以下错误和堆栈跟踪:
getaddrinfo: nodename nor servname provided, or not known
当我在控制台中运行heroku rake resque:work 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
还有针对我的 Facebook 员工:
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))
为什么在不同环境下会出现不同的错误?我的初始化文件看起来像这样:我应该在这里添加ENV规范吗?
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
我的environments/production.rb文件中没有与Redis相关的引用,而我的environments/development.rb文件则包含了以下Redis设置:
ENV["REDISTOGO_URL"] = 'redis://username:password@my.host:6789'