Hello,
Another amazing day today for all of us :)
I am trying to use the AWS EB Ruby 3.0 running on 64bit Amazon Linux 2/3.4.4 with a Ruby-on-Rails v6.0.4.4 app, but until now, I did not manage to make it work
In env status I get:
100.0 % of the requests are failing with HTTP 5xx
also in /var/log/nginx/error.log
[error] 2459#2459: *596 connect() to unix:///var/run/puma/my_app.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 172.31.34.113, server: _, request: "POST / HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/", host: "52.29.66.93"
and in /var/log/puma/puma.log
[4898] ! Unable to start worker
[4898] /opt/rubies/ruby-3.0.3/lib/ruby/site_ruby/3.0.0/bundler/runtime.rb:309:in `check_for_activated_spec!'
[4898] Early termination of worker
The pumactl
it looks ok
[ec2-user@ip-172-31-xx-xx ~]$ pumactl -V
5.6.2
If I check the processes:
ps aux | grep puma
healthd 25925 0.0 3.6 828800 36624 ? Ssl 09:39 0:15 puma 5.3.2 (tcp://127.0.0.1:22221) [healthd]
webapp 26497 0.2 2.2 255768 22912 ? Ss 09:40 1:07 puma 5.6.2 (unix:///var/run/puma/my_app.sock) [current]
webapp 28653 64.0 2.1 327180 21668 ? Rl 16:08 0:00 puma: cluster worker 0: 26497 [current]
ec2-user 28656 0.0 0.0 119420 924 pts/0 S+ 16:08 0:00 grep --color=auto puma
So the puma is running... correct?
Also, there is another puma v5.3.2
Maybe this other puma version is used for another reason (health service)?
In the Rails app I have the following:
.ebextensions/02_yarn.config
commands:
01_node_get:
cwd: /tmp
command: 'curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash -'
02_node_install:
cwd: /tmp
command: 'yum -y install nodejs'
03_yarn_get:
cwd: /tmp
# don't run the command if yarn is already installed (file /usr/bin/yarn exists)
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo'
04_yarn_install:
cwd: /tmp
test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
command: 'sudo yum -y install yarn'
05_mkdir_webapp_dir:
command: "mkdir /home/webapp"
ignoreErrors: true
06_chown_webapp_dir:
command: "chown webapp:webapp /home/webapp"
ignoreErrors: true
07_chmod_webapp_dir:
command: "chmod 0744 /home/webapp"
ignoreErrors: true
08_chmod_logs:
command: "chown webapp:webapp -R /var/app/current/log/"
ignoreErrors: true
09_create_log_file:
command: "touch /var/app/current/log/production.log"
ignoreErrors: true
10_chown_log_production:
command: "chown webapp:webapp /var/app/current/log/production.log"
ignoreErrors: true
11_chmod_log_dir:
command: "chmod 0664 -R /var/app/current/log/"
ignoreErrors: true
12_update_bundler:
command: "gem update bundler"
ignoreErrors: true
13_chown_current:
command: "chown webapp:webapp -R /var/app/current/"
ignoreErrors: true
14_chmod_current:
command: "chmod 0755 -R /var/app/current/"
ignoreErrors: true
15_chown_current:
command: "chown webapp:webapp -R /var/app/ondeck/"
ignoreErrors: true
16_chown_current:
command: "chmod 0644 -R /var/app/ondeck/"
ignoreErrors: true
container_commands:
17_install_webpack:
command: "npm install --save-dev webpack"
18_precompile:
command: "bundle exec rake assets:precompile"
.ebextensions/03_nginx.config
files:
"/etc/nginx/conf.d/02_app_server.conf":
mode: "000644"
owner: root
group: root
content: |
# The content of this file is based on the content of /etc/nginx/conf.d/webapp_healthd.conf
# Change the name of the upstream because it can't have the same name
# as the one defined by default in /etc/nginx/conf.d/webapp_healthd.conf
upstream new_upstream_name {
server unix:///var/run/puma/my_app.sock;
}
# Change the name of the log_format because it can't have the same name
# as the one defined by default in /etc/nginx/conf.d/webapp_healthd.conf
log_format new_log_name_healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';
server {
listen 80;
server_name _ localhost; # need to listen to localhost for worker tier
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/access.log main;
# Match the name of log_format directive which is defined above
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour new_log_name_healthd;
location / {
# Match the name of upstream directive which is defined above
proxy_pass http://new_upstream_name;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /assets {
alias /var/app/current/public/assets;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
location /public {
alias /var/app/current/public;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
location /packs {
alias /var/app/current/public/packs;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
}
container_commands:
01_restart_nginx:
command: "sudo service nginx reload"
Any ideas why it is not working?
Thank you very much in advance for your kind help and support and for your valuable time
I wish to all of us all the best and an amazing continuation in our lives...