通過rails中的delayed_jobs gem(https://github.com/collectiveidea/delayed_job),我可以排隊通知。但我不太瞭解如何在生產服務器上運行排隊的作業。我知道我可以在本地服務器的控制檯上運行在生產服務器上部署後運行延遲作業
$ rake jobs:work
。由於文檔說, 然後,您可以執行以下操作:
RAILS_ENV=production script/delayed_job start
RAILS_ENV=production script/delayed_job stop
# Runs two workers in separate processes.
RAILS_ENV=production script/delayed_job -n 2 start
RAILS_ENV=production script/delayed_job stop
# Set the --queue or --queues option to work from a particular queue.
RAILS_ENV=production script/delayed_job --queue=tracking start
RAILS_ENV=production script/delayed_job --queues=mailers,tasks start
# Runs all available jobs and the exits
RAILS_ENV=production script/delayed_job start --exit-on-complete
# or to run in the foreground
RAILS_ENV=production script/delayed_job run --exit-on-complete
我的問題是如何將它與我的Rails應用程序集成我想創建一個名爲delayed_jobs.rb在配置/初始化文件:
# in config/initializers/delayed_jobs
script/delayed_job start if Rails.env.production?
但我不確定這是否正確的方法來處理它。謝謝