gpt4 book ai didi

ruby-on-rails - Docker Rails 应用程序上没有这样的文件或目录@rb_sysopen sidekiq.pid

转载 作者:行者123 更新时间:2023-12-02 21:13:07 27 4
gpt4 key购买 nike

我试图让它在 EC2 AWS 内运行 rails dockerized 项目容器,但我没有成功运行。

RoR 项目依赖于 sidekiq、postgres 和 redis,因此我使用 docker for rails(Web 服务)和 sidekiq(sidekiq 服务)构建了一个“生产镜像”,目前我尝试使其与 docker-compose 一起用于生产

我不得不说,我本地机器上的一切工作正常。开发和“生产”图像按预期工作,在 EC2 AWS 机器中组合“生产”图像(web 和 sidekiq)时出现问题。

我收到此错误:

production_sidekiq | No such file or directory @ rb_sysopen - /my_app/tmp/pids/sidekiq.pid
production_sidekiq | /usr/local/bundle/gems/sidekiq-4.2.10/lib/sidekiq/cli.rb:370:in `initialize'
production_sidekiq | /usr/local/bundle/gems/sidekiq-4.2.10/lib/sidekiq/cli.rb:370:in `open'
production_sidekiq | /usr/local/bundle/gems/sidekiq-4.2.10/lib/sidekiq/cli.rb:370:in `write_pid'
production_sidekiq | /usr/local/bundle/gems/sidekiq-4.2.10/lib/sidekiq/cli.rb:43:in `parse'
production_sidekiq | /usr/local/bundle/gems/sidekiq-4.2.10/bin/sidekiq:11:in `<top (required)>'
production_sidekiq | /usr/local/bundle/bin/sidekiq:23:in `load'
production_sidekiq | /usr/local/bundle/bin/sidekiq:23:in `<top (required)>'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `load'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:28:in `run'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli.rb:424:in `exec'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli.rb:27:in `dispatch'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli.rb:18:in `start'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/exe/bundle:30:in `block in <top (required)>'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
production_sidekiq | /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.6/exe/bundle:22:in `<top (required)>'
production_sidekiq | /usr/local/bin/bundle:23:in `load'
production_sidekiq | /usr/local/bin/bundle:23:in `<main>'

在我用于 EC2 生产的 docker-compose.yml 中,我有这个:
version: '3'

services:
postgres:
image: postgres:10.5
environment:
POSTGRES_DB: my_app_production
env_file:
- ~/production.env

redis:
image: redis:4.0.11

web:
container_name: prod_web
image: prod_my_app:latest
command: bundle exec rails server -p 3000 -b '0.0.0.0' -e production
ports:
- '80:3000'
depends_on:
- postgres
- redis
environment:
RAILS_ENV: production
RACK_ENV: production
RAILS_LOG_TO_STDOUT: 'true'
RAILS_SERVE_STATIC_FILES: 'true'
EXECJS_RUNTIME: Disabled
SECRET_KEY_BASE: token
DEVISE_SECRET_KEY: token
env_file:
- ~/production.env
restart: always

sidekiq:
container_name: production_sidekiq
image: prod_my_app_sidekiq:latest
command: bundle exec sidekiq -C config/sidekiq.yml
depends_on:
- postgres
- redis
environment:
RAILS_ENV: production
RACK_ENV: production
RAILS_LOG_TO_STDOUT: 'true'
RAILS_SERVE_STATIC_FILES: 'true'
EXECJS_RUNTIME: Disabled
SECRET_KEY_BASE: token
DEVISE_SECRET_KEY: token
env_file:
- ~/production.env
restart: always`

在 config/sidekiq.yml
:verbose: true
:concurrency: 1
:pidfile: ./tmp/pids/sidekiq.pid
staging:
:concurrency: 10
production:
:concurrency: 20
:queues:
- default
- mailers

我被卡住了,我原以为这是卷的问题,因为我有另一个文件用于“本地生产测试图像”和绑定(bind)卷: - .:/my_app 在 sidekiq 和 Web 服务中,所以在生产中我删除了这些行提 Docker Compose in Production但我收到错误 production_sidekiq | No such file or directory @ rb_sysopen - /my_app/tmp/pids/sidekiq.pid
Web 服务上的 Puma 服务器运行正常。

知道发生了什么吗?

最佳答案

你不需要 pidfile 那么为什么要创建一个呢?删除这一行:

:pidfile: ./tmp/pids/sidekiq.pid

关于ruby-on-rails - Docker Rails 应用程序上没有这样的文件或目录@rb_sysopen sidekiq.pid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53233971/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com