AWS Beanstalk - Nhân viên chấm dứt sớm
Sep 25 2020
Tôi muốn lưu trữ ứng dụng rails 6.0.3 (ruby 2.7.1) của mình trên AWS Beanstalk bằng cách sử dụng nền tảng Ruby 2.7 AL2 version 3.1.1. Tôi đã dành hàng giờ để giải quyết các vấn đề sau và cuối cùng, tôi đã mắc kẹt một vấn đề. Khi ứng dụng đang được khởi động, tôi gặp lỗi sau:
/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
Mặt khác, /var/log/web.stdout.lognó có vẻ ổn ...
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
Tôi sử dụng cùng một phiên bản puma như được trỏ trong tài liệu chính thức 4.3.5
Cấu hình / puma.rb của tôi trông giống như sau:
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
Làm thế nào để sửa chữa nó và chạy đúng cách?
Trả lời
wenzel Oct 06 2020 at 15:13
Vui lòng đánh dấu vào những điều sau:
- điều hành sản xuất tại địa phương. Điều này có thể hiển thị cho bạn các lỗi bổ sung (ví dụ: lỗi Zeitwerk)
- kiểm tra quyền theo nhà cung cấp dir, nơi các tệp đá quý đi đến. Một trong những phần phụ thuộc của chúng tôi không có quyền đọc cho người khác và đang gây ra lỗi. Bạn có thể thay đổi điều này bằng cách thêm tập lệnh vào .ebextensions
- Cũng kiểm tra liên kết này: Cây đậu đàn hồi AWS không nhận được các biến môi trường
Trong trường hợp của chúng tôi, chúng tôi trúng jackpot. Đó là tất cả những điều trên ...