本地服务器中的美洲狮错误

时间:2016-03-01 22:57:01

标签: ruby-on-rails-4 heroku puma

我最近在我的应用程序中添加了puma,以便在heroku上获得更好的性能。我的应用程序在生产(实时)环境中运行良好,但我在本地环境中得到错误..

我尝试启动服务器时出现

错误:

Art West@ARTWESTIV ~/desktop/drinkPGH (master)
$ rails s
=> Booting Puma
=> Rails 4.1.8 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[11868] *** SIGUSR2 not implemented, signal based restart unavailable!
[11868] *** SIGUSR1 not implemented, signal based restart unavailable!
[11868] *** SIGHUP not implemented, signal based logs reopening unavailable!
[11868] Puma starting in cluster mode...
[11868] * Version 3.0.2 (ruby 2.1.5-p273), codename: Plethora of Penguin Pinatas
[11868] * Min threads: 5, max threads: 5
[11868] * Environment: development
[11868] * Process workers: 2
[11868] * Preloading application
[11868] * Listening on tcp://0.0.0.0:3000
Exiting
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/cluster.rb:320:in `trap': unsupported signal SIGCHLD (ArgumentError)
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/cluster.rb:320:in `setup_signals'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/cluster.rb:389:in `run'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/launcher.rb:173:in `run'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/rack/handler/puma.rb:51:in `run'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.5/lib/rack/server.rb:264:in `start'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/server.rb:69:in `start'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:81:in `block in server'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `tap'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `server'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

和我的gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'bootstrap-sass'


group :production do 
    gem 'pg'
    gem 'rails_12factor'
    gem 'puma'  
end

group :development, :test do
    gem 'sqlite3'

end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

我的config.puma

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

2 个答案:

答案 0 :(得分:4)

 workers Integer(ENV['WEB_CONCURRENCY'] || 2)

(不是修复)通过评论config / puma.rb的第1行,我能够在开发中运行puma。

workers Integer(ENV['WEB_CONCURRENCY'] || 0) also works

答案 1 :(得分:1)

不积极,这将解决您的问题。我通常使用工头在本地运行应用程序。 rails的puma文档建议启动本地服务器,如下所示:

rails s Puma

它的价值。