问题描述
我试图在AWS Elastic Beanstalk上运行Rails 6应用程序,但是我从puma日志中得到以下内容(每隔几秒钟重复一次)
I'm trying to run a Rails 6 app on AWS Elastic Beanstalk, but I get from puma log the following (repeats every few seconds)
版本号:
- 导轨
6.0.3.3
- 彪马
4.3.5
- ElasticBeanstalk
运行在64位Amazon Linux 2/3.1.1上的Ruby 2.7
- 红宝石
2.7.1p83
服务器从实例外部无响应,并且 log/production.log
上没有任何内容.
The server is unresponsive from outside the instance, and there's nothing on log/production.log
.
在开发机器上以 production
模式运行时,没有错误,并且数据库可以访问(没有迁移失败).
Running on a dev machine on production
mode there's no errors, and the database is reachable (no migration failure).
在AWS实例上运行命令 bundle exec puma -p 3000 -e production
我得到
Running on the AWS instance the command bundle exec puma -p 3000 -e production
I get
Puma starting in single mode...
Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
Min threads: 5, max threads: 5
Environment: production
Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
因此没有明显的错误可能导致工作人员停止工作.
so there's no obvious error that may cause the worker to halt.
我如何找出导致工人失败的原因?
How can I find out what's causing the workers to fail?
我在实例上运行Rails控制台,发现缺少环境变量-例如生产数据库用户/通过/主机.对它们进行硬编码后,就可以连接到数据库了.我怀疑缺少其他环境变量会导致应用崩溃.
I ran Rails console on the instance and found that the environment variables are missing - e.g. the production database user/pass/host. Once I hardcoded them I could connect to the database.I suspect the absence of other environment variables is making the app crash.
推荐答案
AWS论坛上的用户具有答案.
A user on AWS forum had the answer.
设置我的Gemfile
Setting in my Gemfile
gem "nio4r", "= 2.5.2"
解决了该问题.
这篇关于AWS Elastic Beanstalk没有获取环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!