无法在AWS Elastic Beanstalk, AL2上加载Ruby 2.7.4 (Rails 6)应用程序.<



我们有一个Rails应用程序,以前部署在Ruby 2.6平台的AWS Elastic Beanstalk上。由于2.6平台已被AWS弃用,我们不得不升级到Ruby 2.7.4。升级后,我们可以看到应用程序部署成功(从eb-engine.log)…然而,当我点击EB url (xxx.yyyyy.useast1.elasticbeanstalk.com)时,什么也没有显示。我已经验证了nginx和puma都在运行,日志也显示健康检查很好。EB控制台上的环境指示灯也显示为OK。关于我需要寻找什么来调试这个问题的任何提示?

另一个注意事项,如果我首先将EB的示例rails应用程序部署到一个环境,然后将我的应用程序上传到该环境,它开始正常工作…但是,我不想在没有首先弄清楚为什么我无法通过将应用程序直接部署到新环境中来访问它之前就进入生产环境。任何帮助都将非常感激。下面是我的。ebeextensions nginx.config

files:
"/etc/nginx/conf.d/010_app_server.conf":
mode: "000644"
owner: root
group: root
content: |
# based on /etc/nginx/conf.d/webapp_healthd.conf
#
# and notes from "Getting to Know and Love AWS Elastic Beanstalk Configuration Files (.ebextensions)"
# (https://medium.com/trisfera/getting-to-know-and-love-aws-elastic-beanstalk-configuration-files-ebextensions-9a4502a26e3c)
#
# which suggested taking the approach of including a similar
# nginx conf file before webapp_healthd.conf, which has the
# effect of "overriding" the setttings from that file
upstream my_app_new_upstream {
server unix:///var/run/puma/my_app.sock;
}
log_format healthd_new_name '$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;
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd_new_name;
client_max_body_size 100m;
set $should_enforce_https 0;
if ($http_x_forwarded_proto != 'https') {
set $should_enforce_https 1;
}
if ($request_uri ~ ^/pages/health_check$) {
set $should_enforce_https 0;
}
if ($should_enforce_https = 1) {
return 301 https://$host$request_uri;
}
location / {
proxy_pass http://my_app_new_upstream; # match the name of upstream directive which is defined above
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;
}
}
container_commands:
010_reload_nginx:
command: "sudo service nginx reload"

这是puma配置

# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
bind "unix:///var/run/puma/my_app.sock"
pidfile "/var/run/puma/my_app.sock"
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

nginx.conf的路径不正确,要在AL2上覆盖默认的nginx conf,路径应该是.platform/nginx nginx.conf

相关内容

  • 没有找到相关文章

最新更新