ruby-on-rails – 如何在rails应用程序中将sidekiq放入Docker?

我正在使用rails,sidekiq和docker.

我的docker-compose.yml文件

sidekiq:
  build: .
  command: bundle exec sidekiq -C config/sidekiq.yml
  links:
    - db
    - redis

config / sidekiq.yml文件

:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
  - default

运行docker-compose后,sidekiq服务无法正常启动.

sidekiq_1 | No such file or directory @ rb_sysopen - /testapp/tmp/pids/sidekiq.pid
sidekiq_1 | /usr/local/bundle/gems/sidekiq-3.5.3/lib/sidekiq/cli.rb:365:in `initialize'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-3.5.3/lib/sidekiq/cli.rb:365:in `open'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-3.5.3/lib/sidekiq/cli.rb:365:in `write_pid'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-3.5.3/lib/sidekiq/cli.rb:42:in `parse'
sidekiq_1 | /usr/local/bundle/gems/sidekiq-3.5.3/bin/sidekiq:12:in `<top (required)>'
sidekiq_1 | /usr/local/bundle/bin/sidekiq:16:in `load'
sidekiq_1 | /usr/local/bundle/bin/sidekiq:16:in `<main>'
testapp_sidekiq_1 exited with code 1

解决方法

尝试安装卷.您的docker-compose文件应该如下所示(使用Posgtresql作为数据库):
web:
  build: .
  volumes:
    - .:/myapp
  links:
    - db
    - redis
  ports:
    - "3000:3000"
  command: bundle exec rails server -b 0.0.0.0
sidekiq:
  build: .
  volumes:
    - .:/myapp
  links:
    - db
    - redis
  command: bundle exec sidekiq
db:
  image: postgres
redis:
  image: redis

相关文章

以下代码导致我的问题: class Foo def initialize(n=0) @n = n end attr_accessor :n d...
这是我的spec文件,当为上下文添加测试“而不是可单独更新用户余额”时,我得到以下错误. require 's...
我有一个拦截器:DevelopmentMailInterceptor和一个启动拦截器的inititializer setup_mail.rb. 但我想将...
例如,如果我有YAML文件 en: questions: new: 'New Question' other: recent: ...
我听说在RSpec中避免它,let,let !,指定,之前和主题是最佳做法. 关于让,让!之前,如果不使用这些,我该如...
我在Rails中使用MongoDB和mongo_mapper gem,项目足够大.有什么办法可以将数据从Mongoid迁移到 Postgres...