Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
129 views
in Technique[技术] by (71.8m points)

App (rails 6.1.1) can't boot after upgrading to Ruby 3.0

Here is the Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.0'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'

# Flexible authentication solution for Rails with Warden
gem 'devise', '~> 4.7'

# A simple HTTP and REST client
gem 'rest-client', '~> 2.1'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

# Devise supports i18n in controllers, models, and in other areas,
# but it does not have support for internationalized views.
# devise-i18n adds this support.
gem 'devise-i18n', '~> 1.9'
# Devise Bootstrap Views
gem 'devise-bootstrap-views', '~> 1.0'
# Configure Devise to send its emails asynchronously using ActiveJob
gem 'devise-async', '~> 1.0'

# Stripe is the easiest way to accept payments online
gem 'stripe', '~> 5.22'

# A gem that provides a client interface for the Sentry error logger
gem 'sentry-raven', '~> 3.0'

# Taming Rails' Default Request Logging
gem 'lograge', '~> 0.11'

# Ruby state machines
gem 'aasm', '~> 5.0'
# Allows to use ActiveRecord transactional callbacks outside of ActiveRecord models, literally everywhere in your application.
gem 'after_commit_everywhere', '~> 0.1', '>= 0.1.5'

# Agnostic pagination in plain ruby
gem 'pagy', '~> 3.8'

#?Connection Pool
gem 'connection_pool', '~> 2.2'

#?Redis client
gem 'hiredis', '~> 0.6'
gem 'redis', '~> 4.1', require: ['redis', 'redis/connection/hiredis']

# Sidekiq
gem 'sidekiq', '~> 6.0'

# Check password strength against several rules
gem 'password_strength', '~> 1.1'

# Slack Ruby Client
gem 'slack-ruby-client', '~> 0.15'

#?Assets on AWS S3/CloudFront
gem 'asset_sync', '~> 2.12'
gem 'fog-aws', '~> 3.6'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0'
  gem 'rspec-rails', '~> 4.0'
  gem 'amazing_print', '~> 1.2'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'capybara-screenshot'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
  gem 'factory_bot_rails', '~> 6.0'
  gem 'shoulda-matchers', '~> 4.1'
  gem 'rails-controller-testing'
  gem 'faker'
  gem 'database_cleaner-active_record'
  gem 'coderay'
  gem 'mock_redis'
end

The application seems to be blocked during Rails.application.initialize!. I wonder if it could be a gem that is not compatible with Ruby 3.0, but I started a new app from scratch, installed all the gems and the app started normally.

I'm using puma (5.1.1) as web server. The app is running in docker container via docker-compose.

FROM ruby:2.7.2

# Update for security reason
RUN apt-get update -yqq && apt-get upgrade -yqq -o Dpkg::Options::="--force-confold" && apt-get install -yqq --no-install-recommends 
  vim # needed for editing rails credentials

#?Ensure we install an up-to-date version of Node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -

# Ensure latest packages for Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends 
  nodejs 
  yarn

ENV RAILS_ROOT /var/www/app
RUN mkdir -p $RAILS_ROOT

COPY Gemfile* /var/www/app/
WORKDIR /var/www/app

ENV BUNDLE_PATH /gems

RUN bundle install

COPY package.json package.json
COPY yarn.lock yarn.lock

RUN yarn install --check-files

COPY . /var/www/app/

EXPOSE 3000

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENTRYPOINT ["./puma-entrypoint.sh"]
CMD ["bundle", "exec", "puma", "-C", "config/puma/development.rb"]
# 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"

# 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

Is there a way to have logs to see what is happening during boot process?

question from:https://stackoverflow.com/questions/65829106/app-rails-6-1-1-cant-boot-after-upgrading-to-ruby-3-0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please give more information.

  1. On which system are you?
  2. How do you start your application? If you get in trouble, start it always on console.
  3. Puma has a log output. Search for this location. Put log output here.
  4. Try to remove all gems or big part of it to find error.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...