レールで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 アプリと統合する方法です。次のように、config/initializers にdelayed_jobs.rb というファイルを作成することを考えていました。
# in config/initializers/delayed_jobs
script/delayed_job start if Rails.env.production?
しかし、それが正しい方法であるかどうかはわかりません。ありがとう