简体   繁体   中英

AWS elastic beanstalk is not getting the environment variables

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)

[21776] + Gemfile in context: /var/app/current/Gemfile
[21776] Early termination of worker

The version numbers:

  • Rails 6.0.3.3
  • puma 4.3.5
  • ElasticBeanstalk Ruby 2.7 running on 64bit Amazon Linux 2/3.1.1
  • ruby 2.7.1p83

The server is unresponsive from outside the instance, and there's nothing on log/production.log .

Running on a dev machine on production mode there's no errors, and the database is reachable (no migration failure).

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?

Edit 1:

I ran Rails console on the instance and found that the environment variables are missing - eg 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.

A user on AWS forum had the answer .

Setting in my Gemfile

gem "nio4r", "= 2.5.2"

fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM