Dan
Dan

Reputation: 63

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:

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 - 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.

Upvotes: 2

Views: 1665

Answers (1)

Dan
Dan

Reputation: 63

A user on AWS forum had the answer.

Setting in my Gemfile

gem "nio4r", "= 2.5.2"

fixed the issue.

Upvotes: 1

Related Questions