Sidekiq不创建PID文件

Und*_*ion 6 ruby pid config sidekiq

为了阻止Sidekiq,我需要使用:

$bundle exec sidekiqctl stop /Users/me/Documents/sites/some_site/tmp/pid/sidekiq.pid 20

我告诉Sidekiq在config.yml文件中创建一个pid文件:

#/Users/me/Documents/sites/some_site/config.yml
:pidfile: /Users/me/Documents/sites/some_site/tmp/pids/sidekiq.pid
:concurrency: 25
Run Code Online (Sandbox Code Playgroud)

并告诉Sidekiq这个配置文件使用的位置:

$ bundle exec sidekiq -C /Users/me/Documents/sites/some_site/config.yml

但是,当我运行Sidekiq时,它不会创建.pid文件,因此我无法阻止它.那为什么不创建一个.pid文件呢?

Hen*_*hiu 7

尝试用以下方法替换该绝对路径:

:pidfile: ./tmp/pids/sidekiq.pid
Run Code Online (Sandbox Code Playgroud)

其次,确保将运行sidekiq的用户具有写入该目录的正确写入权限.你可以暂时chmod 777进行测试,看看权限是否是问题.

这是Sidekiq的示例配置yml文件.确保您也指定了一个队列.https://github.com/mperham/sidekiq/blob/master/examples/config.yml

  • 谢谢你的建议.正如我在提问中提到的,我已经在使用config.yml文件了.但是我已按照您的建议更改了pid文件的路径并添加了默认队列.我还修改了dir以允许对所有人进行读/写操作.尽管如此,还是没有写入pid文件. (2认同)

Ala*_*ois 5

要使用pidfile,您应该启动sidekiq作为守护进程.当您在rails根目录上使用以下命令启动sidekiq时:

bundle exec sidekiq -d -e development
Run Code Online (Sandbox Code Playgroud)

您可以通过适当的rails环境替换开发.

您还应该在sikekiq configure(config/sidekiq.yml)中指定日志文件.例如:

concurrency: 5
development:
  pidfile: tmp/pids/sidekiq_development.pid
  logfile: log/sidekiq_development.log
beta:
  pidfile: /var/run/sidekiq_beta.log
  logfile: log/sidekiq_beta.pid
staging:
  pidfile: /var/run/sidekiq_stating.pid
  logfile: log/sidekiq_staging.log
production:
  pidfile: /var/run/sidekiq_production.pid
  logfile: log/sidekiq_production.log
  concurrency: 50
Run Code Online (Sandbox Code Playgroud)

如果您使用Debian并且需要启动脚本,那么我可以在Github上使用此Gist:https://gist.github.com/alain75007/5517948