我今天在本地設置了resque-pool,我注意到一些奇怪的行爲。我以前得到普通的老式復甦並沒有問題。我的工作失敗,因爲找不到記錄。當我挖掘到這一點時,我發現這是因爲工人正在設置測試配置。我使用領班/ Heroku的地方和我.ENV文件設置環境RACK_ENV=development
,我也嘗試添加了RACK_ENV=development
resque-pool默認爲測試環境
樣品設置輸出
[OKAY] Loaded ENV .env File as KEY=VALUE Format
5:01:34 PM web.1 | Puma starting in single mode...
5:01:34 PM web.1 | * Version 3.6.0 (ruby 2.3.0-p0), codename: Sleepy Sunday Serenity
5:01:34 PM web.1 | * Min threads: 5, max threads: 5
5:01:34 PM web.1 | * Environment: development
5:01:34 PM worker.1 | resque-pool-manager[curio-api][1751]: Resque Pool running in development environment
5:01:36 PM web.1 | * Listening on tcp://0.0.0.0:3000
5:01:36 PM web.1 | Use Ctrl-C to stop
5:01:36 PM worker.1 | resque-pool-manager[curio-api][1751]: started manager
我的任務/ resque.rake文件
require 'resque/pool/tasks'
# this task will get called before resque:pool:setup
# and preload the rails environment in the pool manager
task "resque:setup" => :environment do
# generic worker setup, e.g. Hoptoad for failed jobs
end
task "resque:pool:setup" => :environment do
# close any sockets or files in pool manager
ActiveRecord::Base.connection.disconnect!
# and re-open them in the resque worker parent
Resque::Pool.after_prefork do |job|
ActiveRecord::Base.establish_connection
end
end
我不知道爲什麼沒有挑選環境變量。我也有點驚訝,resque-pool是默認測試。我在rails 5.0 api only app中使用0.6.0。我敢肯定,我必須做一些愚蠢的,但我不能看到它它
萬一有幫助,有byebug亂搞
✗ resque-pool
[7, 16] in /Users/conornugent/Dev/neighbourwood/curio/curio-api/lib/tasks/resque.rake
7: end
8:
9: task "resque:pool:setup" => :environment do
10: # close any sockets or files in pool manager
11: byebug
=> 12: ActiveRecord::Base.connection.disconnect!
13: # and re-open them in the resque worker parent
14: Resque::Pool.after_prefork do |job|
15: ActiveRecord::Base.establish_connection
16: end
(byebug) Rails.env
"test"
(byebug) ActiveRecord::Base.connection.current_database
"curio-api_test"
我張貼了關於這個問題,但我猜測這可能是因爲現代的東西,我這樣做,這可能是更合適的家我的查詢
https://github.com/nevans/resque-pool/issues/158