Ruby on rails 在Docker中启动sidekiq时出错:“0”;请将sidekiq指向Rails 4/5应用程序“;
Rails 5.2,Docker Compose,Sidekiq,Redis 这是docker compose文件:Ruby on rails 在Docker中启动sidekiq时出错:“0”;请将sidekiq指向Rails 4/5应用程序“;,ruby-on-rails,docker,redis,sidekiq,Ruby On Rails,Docker,Redis,Sidekiq,Rails 5.2,Docker Compose,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:
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
然后我得到这个错误:
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"?
Spring无法找到您的config/application.rb文件。你的
在/api中检测到项目根,因此spring查找
/api/config/application.rb,但它不存在。您可以配置
通过将Spring.application\u root设置为
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在其容器中正确启动呢
我已经看到了这些答案,它们是相似的,但不是这个特定的错误:
sidekiq似乎找不到Rails应用程序,这是通过添加“工作目录”设置修复的,然后它找不到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:
sidekiq似乎找不到Rails应用程序,这是通过添加“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:
谢谢你。这也为我解决了问题。@paulmiller3000我很高兴。谢谢你的投票!谢谢你。这也为我解决了问题。@paulmiller3000我很高兴。谢谢你的投票!