AWS Beanstalk-작업자 조기 종료
Sep 25 2020
platform을 사용하여 AWS Beanstalk에서 rails 6.0.3 (ruby 2.7.1) 앱을 호스팅하고 싶습니다 Ruby 2.7 AL2 version 3.1.1. 나는 다음 문제를 해결하기 위해 몇 시간을 보냈고 마침내 나는 하나를 얻었습니다. 앱이 시작될 때 다음 오류가 발생합니다.
/var/log/puma/puma.log
[10222] Early termination of worker
[10258] + Gemfile in context: /var/app/current/Gemfile
[10258] Early termination of worker
[31408] - Gracefully shutting down workers...
=== puma startup: 2020-09-25 13:33:02 +0000 ===
=== puma startup: 2020-09-25 13:33:02 +0000 ===
[10501] + Gemfile in context: /var/app/current/Gemfile
[10501] Early termination of worker
[10504] + Gemfile in context: /var/app/current/Gemfile
[10504] Early termination of worker
반면에 /var/log/web.stdout.log괜찮아 보이는 것 같습니다 ...
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] Puma starting in cluster mode...
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Min threads: 8, max threads: 32
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Environment: staging
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Process workers: 1
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Phased restart available
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Listening on unix:///var/run/puma/my_app.sock
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] Use Ctrl-C to stop
공식 문서에서 지적한 것과 동일한 퓨마 버전을 사용합니다. 4.3.5
내 config / puma.rb는 다음과 같습니다.
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 `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 } # <------ uncomment this line
# 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! # <------ uncomment this line
# Allow Puma to be restarted by the `Rails restart` command.
plugin :tmp_restart
문제를 해결하고 제대로 실행하는 방법은 무엇입니까?
답변
wenzel Oct 06 2020 at 15:13
다음을 확인하십시오.
- 로컬에서 프로덕션을 실행합니다. 추가 오류 (예 : Zeitwerk 오류)를 표시 할 수 있습니다.
- gem 파일이있는 공급 업체 디렉토리에서 권한을 확인하십시오. 종속성 중 하나에 다른 사용자에 대한 읽기 권한이 없었고 오류가 발생했습니다. .ebextensions에 스크립트를 추가하여이를 변경할 수 있습니다.
- 이 링크도 확인하십시오. AWS Elastic Beantalk가 환경 변수를 가져 오지 않습니다.
우리의 경우에는 대박을 쳤습니다. 위의 모든 것이 었습니다 ...