Sidekiq-cron 在没有 ssh 到生产服务器的情况下无法工作



我在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/ininitializer/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

Gemfile

gem 'redis'
gem 'sidekiq'
gem 'sidekiq-cron'
gem 'capistrano-sidekiq'

sidekiq 6.1.2 版本

我修复了它:

loginctl enable-linger deploy
systemctl --user daemon-reload
systemctl --user stop sidekiq-production.service
systemctl --user daemon-reload
systemctl --user start sidekiq-production.service
systemctl --user enable sidekiq-production.service

相关内容

  • 没有找到相关文章

最新更新