升级到 Rails 6.1.3 后,Rails 应用程序无法在 AWS 上运行

升级到 Rails 6.1.3 后,Rails 应用程序无法在 AWS 上运行

我最近将我的应用程序升级到了 Rails 6.1.3。当我尝试将应用程序部署到 AWS 时,部署失败,并显示错误消息“以下服务未运行:应用程序。”。我尝试在本地和通过 ssh 进入 AWS 实例来运行该应用程序,因此我不确定为什么 Amazon 的自动部署脚本无法启动它。

应用程序部署失败后,CPU使用率也保持在100%。

我的 Puma 文件是

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

这是我的 eb-activity.log

  perl-Sub-Install.noarch 0:0.926-6.8.amzn1
  perl-TimeDate.noarch 1:2.30-2.7.amzn1
  perl-Try-Tiny.noarch 0:0.12-2.5.amzn1
  perl-URI.noarch 0:1.60-9.8.amzn1
  perl-WWW-RobotRules.noarch 0:6.02-5.12.amzn1
  perl-libwww-perl.noarch 0:6.05-2.17.amzn1
  
  Complete!
  Installing cloud watch tools
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  Dload  Upload   Total   Spent    Left  Speed
  
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  100 24225  100 24225    0     0   271k      0 --:--:-- --:--:-- --:--:--  271k
  Archive:  CloudWatchMonitoringScripts-1.2.2.zip
  extracting: aws-scripts-mon/awscreds.template
  inflating: aws-scripts-mon/AwsSignatureV4.pm
  inflating: aws-scripts-mon/CloudWatchClient.pm
  inflating: aws-scripts-mon/LICENSE.txt
  inflating: aws-scripts-mon/mon-get-instance-stats.pl
  inflating: aws-scripts-mon/mon-put-instance-data.pl
  inflating: aws-scripts-mon/NOTICE.txt
  Setting shell script permissions
  Installing cron script
  
[2021-03-25T04:56:06.367Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Cosmic_Delivery_Production_Website] : Completed activity.
[2021-03-25T04:56:06.367Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Completed activity.
[2021-03-25T04:56:06.403Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage0/EbExtensionPostBuild] : Completed activity.
[2021-03-25T04:56:06.403Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage0/InfraCleanEbextension] : Starting activity...
[2021-03-25T04:56:06.445Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage0/InfraCleanEbextension] : Completed activity. Result:
  Cleaned ebextensions subdirectories from /var/app/ondeck.
[2021-03-25T04:56:06.445Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage0] : Completed activity. Result:
  Application deployment - Command CMD-SelfStartup stage 0 completed
[2021-03-25T04:56:06.445Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1] : Starting activity...
[2021-03-25T04:56:06.445Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook] : Starting activity...
[2021-03-25T04:56:06.450Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/01_flip.sh] : Starting activity...
[2021-03-25T04:56:06.793Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/01_flip.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir
  + EB_APP_STAGING_DIR=/var/app/ondeck
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir
  + EB_APP_DEPLOY_DIR=/var/app/current
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_user
  + EB_APP_USER=webapp
  + '[' -d /var/app/current ']'
  + mv /var/app/current /var/app/current.old
  + mv /var/app/ondeck /var/app/current
  + mkdir -p /var/app/current/tmp /var/app/current/public
  + chown -R webapp:webapp /var/app/current/tmp /var/app/current/public
  + nohup rm -rf /var/app/current.old
[2021-03-25T04:56:06.793Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/01stop_xray.sh] : Starting activity...
[2021-03-25T04:56:08.916Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/01stop_xray.sh] : Completed activity. Result:
  Executing: if ( initctl status xray | grep start ); then initctl stop xray; fi
  xray start/running, process 2278
  xray stop/waiting
[2021-03-25T04:56:08.916Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/02_restart_app_server.sh] : Starting activity...
[2021-03-25T04:56:08.922Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/02_restart_app_server.sh] : Completed activity. Result:
  + initctl restart puma
  initctl: Unknown instance: 
  + initctl start puma
  puma start/running, process 8214
[2021-03-25T04:56:08.922Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/02start_xray.sh] : Starting activity...
[2021-03-25T04:56:09.155Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/02start_xray.sh] : Completed activity.
[2021-03-25T04:56:09.155Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/28_create_pids.sh] : Starting activity...
[2021-03-25T04:56:39.577Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook/28_create_pids.sh] : Completed activity. Result:
  + /opt/elasticbeanstalk/bin/healthd-track-pidfile --proxy nginx
  ++ /opt/elasticbeanstalk/bin/get-config container -k puma_pid_dir
  + PUMA_PID_DIR=/var/run/puma
  + /opt/elasticbeanstalk/bin/healthd-track-pidfile --name application --location /var/run/puma/puma.pid
[2021-03-25T04:56:39.578Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployEnactHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/enact.
[2021-03-25T04:56:39.578Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployPostHook] : Starting activity...
[2021-03-25T04:56:39.578Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployPostHook/01_rails_support.sh] : Starting activity...
[2021-03-25T04:56:39.991Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployPostHook/01_rails_support.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir
  + EB_APP_DEPLOY_DIR=/var/app/current
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_log_dir
  + EB_APP_LOG_DIR=/var/app/containerfiles/logs
  + ln -sf /var/app/current/log/delayed_job.log /var/app/current/log/development_inner.log /var/app/current/log/development.log /var/app/current/log/production.log /var/app/current/log/test.log /var/app/current/log/worker_inner.log /var/app/containerfiles/logs
[2021-03-25T04:56:39.991Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/AppDeployPostHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/post.
[2021-03-25T04:56:39.991Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/PostInitHook] : Starting activity...
[2021-03-25T04:56:39.992Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1/PostInitHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/postinit.
[2021-03-25T04:56:39.992Z] INFO  [3111]  - [Application deployment Version1.32.20@9/StartupStage1] : Completed activity. Result:
  Application deployment - Command CMD-SelfStartup stage 1 completed
[2021-03-25T04:56:39.992Z] INFO  [3111]  - [Application deployment Version1.32.20@9/AddonsAfter] : Starting activity...
[2021-03-25T04:56:39.992Z] INFO  [3111]  - [Application deployment Version1.32.20@9/AddonsAfter/ConfigLogRotation] : Starting activity...
[2021-03-25T04:56:39.992Z] INFO  [3111]  - [Application deployment Version1.32.20@9/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
[2021-03-25T04:56:40.170Z] INFO  [3111]  - [Application deployment Version1.32.20@9/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result:
  Disabled forced hourly log rotation.
[2021-03-25T04:56:40.170Z] INFO  [3111]  - [Application deployment Version1.32.20@9/AddonsAfter/ConfigLogRotation] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
[2021-03-25T04:56:40.170Z] INFO  [3111]  - [Application deployment Version1.32.20@9/AddonsAfter] : Completed activity.
[2021-03-25T04:56:40.170Z] INFO  [3111]  - [Application deployment Version1.32.20@9] : Completed activity. Result:
  Application deployment - Command CMD-SelfStartup succeeded
[2021-03-25T04:57:31.185Z] INFO  [10744] - [CMD-TailLogs] : Starting activity...
[2021-03-25T04:57:31.185Z] INFO  [10744] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2021-03-25T04:57:31.185Z] INFO  [10744] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2021-03-25T04:57:31.186Z] INFO  [10744] - [CMD-TailLogs/TailLogs] : Starting activity...
[2021-03-25T04:57:31.186Z] INFO  [10744] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...

这是我在另一个日志中遇到的 puma 错误

2021/03/25 04:24:05 [crit] 3116#0: *1 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.31.115, server: _, request: "GET /status/healthcheck HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/status/healthcheck", host: "172.31.33.122"

我已经研究这个问题一段时间了,但不知道是什么原因导致了这个问题。我想知道是否有人可以给我指明正确的方向。

答案1

您需要使用支持 Ruby 3 堆栈的 puma 版本“5.5.2”。https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platform-history-ruby.html

相关内容