在PUMA 2.16.0上运行Rails 2.3应用程序时出错

时间:2019-01-01 13:02:43

标签: ruby-on-rails puma

试图在带有rvm的ubuntu上运行Rails 2.3 ruby​​ 1.8.7应用 使用'script / server'命令与webrick一起正常运行 之后,我尝试通过安装gem puma 2.16.0与puma一起运行

我尝试了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

也尝试过 rackup -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

0 个答案:

没有答案