Ошибка при запуске приложения rails 2.3 с puma 2.16.0 - PullRequest
0 голосов
/ 01 января 2019

попытка запустить приложение rails 2.3 ruby ​​1.8.7 в Ubuntu с rvm нормально работает с webrick с помощью команды 'script / server', после чего я попытался запустить его с puma, установив gem puma 2.16.0

я пробовал puma -C puma / config.rb config.ru, выдавая ошибку

Puma starting in single mode...
* Version 2.16.0 (ruby 1.8.7-p376), codename: Midwinter Nights Trance
* Min threads: 5, max threads: 5
* Environment: development
! Unable to load application: NoMethodError: undefined method `parse_file' for Rack::Builder:Class
/home/ashish/.rvm/gems/ruby-1.8.7-head/gems/puma-2.16.0/lib/puma/configuration.rb:155:in `load_rackup': undefined method `parse_file' for Rack::Builder:Class (NoMethodError)
        from /home/ashish/.rvm/gems/ruby-1.8.7-head/gems/puma-2.16.0/lib/puma/configuration.rb:99:in `app'
        from /home/ashish/.rvm/gems/ruby-1.8.7-head/gems/puma-2.16.0/lib/puma/runner.rb:114:in `load_and_bind'
        from /home/ashish/.rvm/gems/ruby-1.8.7-head/gems/puma-2.16.0/lib/puma/single.rb:79:in `run'
        from /home/ashish/.rvm/gems/ruby-1.8.7-head/gems/puma-2.16.0/lib/puma/cli.rb:214:in `run'
        from /home/ashish/.rvm/gems/ruby-1.8.7-head/gems/puma-2.16.0/bin/puma:10
        from /home/ashish/.rvm/gems/ruby-1.8.7-head/bin/puma:19:in `load'
        from /home/ashish/.rvm/gems/ruby-1.8.7-head/bin/puma:19

также пробовал рэкап -s puma какая-то другая ошибка

вот мой config.ru

# This file is used by Rack-based servers to start the application.
require File.dirname(__FILE__) + '/config/environment'
#require_relative 'config/environment'

use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new

вот мое окружение. Rb

require File.join(File.dirname(__FILE__), 'boot')


RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION

Rails::Initializer.run do |config|
  config.time_zone = 'UTC'
  config.gem 'declarative_authorization', :source => 'http://gemcutter.org'

  config.load_once_paths += %W( #{RAILS_ROOT}/lib )
  config.load_paths += Dir["#{RAILS_ROOT}/app/models/*"].find_all { |f| File.stat(f).directory? }

  config.reload_plugins = true if RAILS_ENV =="development"
  config.plugins = [:paperclip,:all]

  if (File.exist?('config/smtp_settings.yml'))
    SMTP_SETTINGS = YAML.load_file('config/smtp_settings.yml')[RAILS_ENV]
    if SMTP_SETTINGS      
      config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = SMTP_SETTINGS
    end
  end

end  

SMTP_SETTINGS = ActionMailer::Base.smtp_settings unless defined? SMTP_SETTINGS

puma.rb

# app_dir = File.expand_path("/..", __FILE__)
# directory app_dir
# rackup "#{app_dir}/config.ru"

# 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.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, 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 number of `workers` to boot in clustered mode.
# Workers are forked webserver 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. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!

# If you are preloading your application and using Active Record, it's
# recommended that you close any connections to the database before workers
# are forked to prevent connection leakage.
#
# before_fork do
#   ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
# end

# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted, this block will be run. If you are using the `preload_app!`
# option, you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, as Ruby
# cannot share connections between processes.
#
# on_worker_boot do
#   ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
#

# Allow puma to be restarted by `rails restart` command.
# plugin :tmp_restart
...