在 Docker 中启动 sidekiq 时出错:"Please point sidekiq to a Rails 4/5 application"
Error starting sidekiq in Docker: "Please point sidekiq to a Rails 4/5 application"
Rails 5.2,Docker 编写,Sidekiq,Redis。
这是 docker-compose 文件:
version: '3.6'
services:
redis:
image: 'redis:4.0-alpine'
command: redis-server
ports:
- '6379:6379'
volumes:
- 'redis:/data'
sidekiq:
depends_on:
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- './:/app'
env_file:
- '.env'
api:
build: .
volumes:
- './:/app'
working_dir: /app
command: puma
ports:
- 3000:3000
depends_on:
- db
- redis
environment:
DATABASE_URL: postgres://postgres@db
db:
image: postgres:10.3-alpine
volumes:
redis:
postgres:
sidekiq 似乎找不到我的 Rails 应用程序。
如果我把sidekiq改成这样开始:
command: bundle exec sidekiq -C config/sidekiq.yml -r /app
然后我得到这个错误:
Spring was unable to find your config/application.rb file. Your
project root was detected at /api, so spring looked for
/api/config/application.rb but it doesn't exist. You can configure the
root of your application by setting Spring.application_root in
config/spring.rb.
如果我改为将 working_dir
设置添加到 sidekiq:
sidekiq:
depends_on:
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- './:/app'
env_file:
- '.env'
working_dir:
- '/app'
然后我得到这个错误:
2019-05-27T20:27:59.770Z 1 TID-gr1e0d7n5 INFO: Booting Sidekiq 5.1.1 with redis options {:url=>"redis://redis:6379/0", :id=>"Sidekiq-server-PID-1"}
sidekiq_1 | could not connect to server: No such file or directory
sidekiq_1 | Is the server running locally and accepting
sidekiq_1 | connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
那么如何让sidekiq在容器中正确启动呢?
我看到了这些答案,它们很相似但不是这个特定的错误:
Question 4
sidekiq好像找不到Railsapp,通过添加'working-dir'设置修复,然后找不到postgres,只好添加环境设置指向到 postgres。
最终合成文件为:
version: '3.6'
services:
db:
image: postgres:10.3-alpine
ports:
- '5432:5432'
redis:
image: 'redis:4.0-alpine'
command: redis-server
ports:
- '6379:6379'
volumes:
- 'redis:/data'
sidekiq:
depends_on:
- 'db'
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- './:/app'
env_file:
- '.env'
working_dir: /app
environment:
DATABASE_URL: postgres://postgres@db
api:
build: .
volumes:
- './:/app'
working_dir: /app
command: puma
ports:
- 3000:3000
depends_on:
- db
- redis
environment:
DATABASE_URL: postgres://postgres@db
volumes:
redis:
postgres:
Rails 5.2,Docker 编写,Sidekiq,Redis。
这是 docker-compose 文件:
version: '3.6'
services:
redis:
image: 'redis:4.0-alpine'
command: redis-server
ports:
- '6379:6379'
volumes:
- 'redis:/data'
sidekiq:
depends_on:
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- './:/app'
env_file:
- '.env'
api:
build: .
volumes:
- './:/app'
working_dir: /app
command: puma
ports:
- 3000:3000
depends_on:
- db
- redis
environment:
DATABASE_URL: postgres://postgres@db
db:
image: postgres:10.3-alpine
volumes:
redis:
postgres:
sidekiq 似乎找不到我的 Rails 应用程序。
如果我把sidekiq改成这样开始:
command: bundle exec sidekiq -C config/sidekiq.yml -r /app
然后我得到这个错误:
Spring was unable to find your config/application.rb file. Your project root was detected at /api, so spring looked for /api/config/application.rb but it doesn't exist. You can configure the root of your application by setting Spring.application_root in config/spring.rb.
如果我改为将 working_dir
设置添加到 sidekiq:
sidekiq:
depends_on:
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- './:/app'
env_file:
- '.env'
working_dir:
- '/app'
然后我得到这个错误:
2019-05-27T20:27:59.770Z 1 TID-gr1e0d7n5 INFO: Booting Sidekiq 5.1.1 with redis options {:url=>"redis://redis:6379/0", :id=>"Sidekiq-server-PID-1"}
sidekiq_1 | could not connect to server: No such file or directory
sidekiq_1 | Is the server running locally and accepting
sidekiq_1 | connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
那么如何让sidekiq在容器中正确启动呢?
我看到了这些答案,它们很相似但不是这个特定的错误:
Question 4
sidekiq好像找不到Railsapp,通过添加'working-dir'设置修复,然后找不到postgres,只好添加环境设置指向到 postgres。
最终合成文件为:
version: '3.6'
services:
db:
image: postgres:10.3-alpine
ports:
- '5432:5432'
redis:
image: 'redis:4.0-alpine'
command: redis-server
ports:
- '6379:6379'
volumes:
- 'redis:/data'
sidekiq:
depends_on:
- 'db'
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- './:/app'
env_file:
- '.env'
working_dir: /app
environment:
DATABASE_URL: postgres://postgres@db
api:
build: .
volumes:
- './:/app'
working_dir: /app
command: puma
ports:
- 3000:3000
depends_on:
- db
- redis
environment:
DATABASE_URL: postgres://postgres@db
volumes:
redis:
postgres: