[英]AWS elastic beanstalk 100.0 % of the requests are erroring with HTTP 4xx
[英]AWS Elastic Beanstalk - Ruby 3.0 running on 64bit Amazon Linux 2/3.4.4 - 100.0 % of the requests are failing with HTTP 5xx
今天對我們所有人來說又是美好的一天:)
我正在嘗試使用運行在 64 位 Amazon Linux 2/3.4.4 上的 AWS EB Ruby 3.0 和 Ruby-on-Rails v6.0.4.4 應用程序,但直到現在,我還沒有設法讓它工作
在環境狀態下,我得到:
100.0 % of the requests are failing with HTTP 5xx
也在 /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"
在 /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
pumactl
看起來不錯
[ec2-user@ip-172-31-xx-xx ~]$ pumactl -V
5.6.2
如果我檢查流程:
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
所以美洲獅在跑……對嗎?
此外,還有另一個 puma v5.3.2
也許其他 puma 版本是出於其他原因(健康服務)使用的?
在 Rails 應用程序中,我有以下內容:
.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"
任何想法為什么它不起作用?
在.ebextensions/03_nginx.config
的files
部分中有/etc/nginx/conf.d/02_app_server.conf
的條目,但沒有這樣的文件:
ls -ls /etc/nginx/conf.d/
total 8
0 drwxr-xr-x 2 root root 45 Apr 8 15:42 elasticbeanstalk
4 -rw-r--r-- 1 root root 62 Apr 8 15:42 elasticbeanstalk-nginx-ruby-upstream.conf
4 -rw-r--r-- 1 root root 147 Apr 8 15:42 healthd_logformat.conf
這個可以嗎?
非常感謝您的幫助和支持以及您寶貴的時間
我希望我們所有人都能在我們的生活中一切順利和精彩的延續......
由於您使用的是Amazon Linux 2
,因此您的 nginx 設置將永遠不起作用。 這是因為它們適用於 AL1,但您使用的是 AL2。 您的所有 nginx 設置都應通過.platform/nginx/conf.d/
定義,而不是.ebextentions
,如文檔中所述。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.