首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在64位AmazonLinux2/3.4.4上运行的AWS弹性豆柄-Ruby3.0- 100.0 %的请求在HTTP5xx中失败

在64位AmazonLinux2/3.4.4上运行的AWS弹性豆柄-Ruby3.0- 100.0 %的请求在HTTP5xx中失败
EN

Stack Overflow用户
提问于 2022-04-11 03:53:00
回答 1查看 317关注 0票数 0

今天,对我们所有人来说,又是一个令人惊奇的日子:)

我试图使用运行在64位Amazon 2/3.4.4上的AWS EB Ruby3.0和Rails v6.0.4.4应用程序,但直到现在,我还没有设法使它工作。

在env状态下,我得到:

代码语言:javascript
复制
100.0 % of the requests are failing with HTTP 5xx

也在/var/log/nginx/error.log中

代码语言:javascript
复制
[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中

代码语言:javascript
复制
[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看上去还行

代码语言:javascript
复制
[ec2-user@ip-172-31-xx-xx ~]$ pumactl -V
5.6.2

如果我检查这些过程:

代码语言:javascript
复制
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

所以美洲狮跑了..。对,是这样?

另外,还有另一只美洲狮5.3.2

也许这另一个美洲豹版本是出于另一个原因(卫生服务)?

在Rails应用程序中,我有以下内容:

.eb扩展名/02_yarn.config

代码语言:javascript
复制
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"

.eb扩展名/03_nginx.config

代码语言:javascript
复制
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条目,但是没有这样的文件:

代码语言:javascript
复制
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

这样可以吗?

非常感谢您的帮助和支持,感谢您宝贵的时间。

我祝愿我们所有的人在我们的生活中一切顺利和令人惊奇.

EN

回答 1

Stack Overflow用户

发布于 2022-04-11 04:59:59

由于您使用的是Amazon Linux 2,您的nginx设置将永远无法工作。这是因为它们是用于AL1的,但是您使用的是AL2。所有的nginx设置都应该通过.platform/nginx/conf.d/来定义,而不是像文档中解释的那样定义.ebextentions

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71822552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档