【问题标题】:Sidekiq-cron doesn't work without ssh to production server如果没有 ssh 到生产服务器,Sidekiq-cron 将无法工作
【发布时间】:2021-04-02 23:41:54
【问题描述】:

我在 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 版本

【问题讨论】:

  • 请添加sidekiq-cron配置。
  • 你也可以加你的Gemfile吗?sidekiq的版本是什么

标签: ruby sidekiq ruby-on-rails-6 production sidekiq-cron


【解决方案1】:

我修好了:

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

【讨论】:

    猜你喜欢
    • 2021-03-29
    • 1970-01-01
    • 2014-05-22
    • 2019-11-10
    • 2022-12-03
    • 1970-01-01
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    相关资源
    最近更新 更多