我在 Ruby on Rails 上有应用程序。它有电子邮件邮寄。部署后我的 sidekiq-cron 不发送电子邮件。工人没有开始工作。它仅在我连接到 ssh 上的服务器时才有效。谁能帮我?Sidekiq-cron 在本地工作。
我用
grep sidekiq /var/log/syslog
当我与服务器断开连接时,我看到:
Stopping sidekiq for kdl (production)...
pid=20692 tid=6hkqs INFO: Shutting down
pid=20692 tid=13ozxo INFO: Scheduler exiting...
pid=20692 tid=6hkqs INFO: Terminating quiet workers
pid=20692 tid=13p0b0 INFO: Scheduler exiting...
pid=20692 tid=6hkqs INFO: Pausing to allow workers to finish...
pid=20692 tid=6hkqs INFO: Bye!
当我通过 ssh 连接时
pid=21478 tid=2fo8q INFO: Cron Jobs - add job with name: test_cron_minutes
pid=21478 tid=2fo8q INFO: Booted Rails 6.0.3.4 application in production environment
pid=21478 tid=2fo8q INFO: Running in ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
pid=21478 tid=2fo8q INFO: See LICENSE and the LGPL-3.0 for licensing details.
pid=21478 tid=2fo8q INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
/config/initializer/sidekiq.rb
schedule_file = 'config/schedule.yml'
if File.exist?(schedule_file) && Sidekiq.server?
Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
end
/config/sidekiq.yml
:concurrency: 1
:queues:
-default
-mailers
-test_worker
-send_to_subscribed_worker
/config/schedule.yml
send_to_subscribed_job:
cron: "0 12 * * Mon,Thu"
class: "SendToSubscribedWorker"
queue: send_to_subscribed_worker
test_cron_minutes:
cron: "* * * * *"
class: "TestWorker"
queue: test_worker
宝石文件
gem 'redis'
gem 'sidekiq'
gem 'sidekiq-cron'
gem 'capistrano-sidekiq'
sidekiq 6.1.2 版本