puma fails to launch in production, throws Unable to load application: NoMethodError: `process' for #<Class:0x000000065f8ee8>

puma fails to launch in production, throws Unable to load application: NoMethodError: `process' for #<Class:0x000000065f8ee8>

我在 Rails 应用程序上有一个 Ruby,它 运行 正在开发中,但是一旦部署到生产环境,puma 就无法启动。我整天都在调试和谷歌搜索这件事,但无济于事。

我已经尝试从生产服务器上完全删除此应用程序并从头开始。相同的结果。

我试过不同版本的 puma -- 没有区别。

我试过以不同的方式对 Gemfile 进行排序——没有成功。

我已经查找了 ckeditor、mini_magick 和 carrierwave 的已知问题,但到目前为止没有发现任何有用的信息。

mekilacms gem 是我为这个项目修改的 Wellspring 版本。我没有发现任何与 Wellspring 相关的信息。

老实说,我运行没主意了。真的很感激这方面的一些帮助。

这里是 puma.error.log,它显示了我遇到的问题:

=== puma startup: 2017-05-08 17:35:06 -0400 ===
! Unable to load application: NoMethodError: undefined method `process' for #<Class:0x000000065f8ee8>
Did you mean?  proc
bundler: failed to load command: puma (/home/www-data/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bin/puma)

无论是 运行 来自 Capistrano 还是作为部署用户来自命令行,都会发生这种情况。

这是在命令行上向上滚动的内容:

Puma starting in single mode...
* Version 3.6.2 (ruby 2.3.0-p0), codename: Sleepy Sunday Serenity
* Min threads: 4, max threads: 16
* Environment: production
! Unable to load application: NoMethodError: undefined method `process' for #<Class:0x000000065f55b8>
Did you mean?  proc
bundler: failed to load command: puma (/home/www-data/apps/TrueSelfAcademy    /shared/bundle/ruby/2.3.0/bin/puma)
NoMethodError: undefined method `process' for #<Class:0x000000065f55b8>
Did you mean?  proc
/home/www-data/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0 /gems/activerecord-5.0.1/lib/active_record/dynamic_matchers.rb:21:in `method_missing'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/ckeditor-11d3a5b90564/lib/ckeditor/backend/carrierwave.rb:14:in `block in extended'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/ckeditor-11d3a5b90564/lib/ckeditor/backend/carrierwave.rb:13:in `class_eval'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/ckeditor-11d3a5b90564/lib/ckeditor/backend/carrierwave.rb:13:in `extended'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/ckeditor-11d3a5b90564/lib/ckeditor/backend/carrierwave.rb:8:in `extend'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/ckeditor-11d3a5b90564/lib/ckeditor/backend/carrierwave.rb:8:in `included'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/MeKila-CMS-f997bb08ed5d/app/models/mekilacms/asset.rb:4:in `include'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/MeKila-CMS-f997bb08ed5d/app/models/mekilacms/asset.rb:4:in `<class:Asset>'
/var/www/apps/TrueSelfAcademy/shared/bundle/ruby/2.3.0/bundler/gems/MeKila-CMS-f997bb08ed5d/app/models/mekilacms/asset.rb:1:in `<top (required)>'
<...snip...>

环境: Rails 5.0.1, Ruby 2.4.0rc1 (2016-12-12 t运行k 57064) [x86_64-linux], Ubuntu 服务器 16.04(生产和开发——完全更新) rvm 1.28.0, 捆绑器 1.14.6.

Capistrano Version: 3.8.1 (Rake Version: 12.0.0) 用于执行部署到生产环境,完成无误。

这是 Gemfile:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
#use postgresql as the database
gem 'pg'
# Use Puma as the app server
gem 'puma', '3.6.2'  # 3.7.0 has bug which results in no socket being created
# Use SCSS for stylesheets
gem 'sass-rails', '>= 5.0.6'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
# Sprockets
gem 'sprockets', '3.6.3'
# Use Bootstrap for site CSS
gem 'bootstrap-sass'
gem 'twitter-bootswatch-rails'
gem 'twitter-bootswatch-rails-helpers'
gem 'twitter-bootswatch-rails-fontawesome'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# 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.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'


gem 'devise'
# gem 'toastr-rails'
gem 'remotipart', github: 'mshibuya/remotipart'
gem 'rails_admin', '>= 1.0.0.rc'
gem 'cancancan'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
  gem 'spring-commands-rspec'
  gem 'database_cleaner'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
end

group :development do
  # Access an IRB console on exception pages or by using <%= 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.0'
  gem 'capistrano',            require: false
  gem 'capistrano-rvm',        require: false
  gem 'capistrano-rails',      require: false
  gem 'capistrano-bundler',    require: false
  gem 'capistrano3-puma',      require: false

end

group :test do
  gem 'capybara'
  gem 'selenium-webdriver'
end

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

# Capture user's timezone from their browser
gem 'browser-timezone-rails'

gem 'yaml_db'
gem 'rails-html-sanitizer'

# WYSIWYG functionality
gem 'carrierwave'
gem 'mini_magick'
gem 'ckeditor', :git => 'git://github.com/galetahub/ckeditor.git'

# CMS functionality
#gem 'mekilacms', path: '../mekilacms/'
gem 'mekilacms', :git => 'git@maitaikawika.hopto.org:david/MeKila-CMS.git'

这是 Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
install_plugin Capistrano::Puma
require 'capistrano/scm/git'
install_plugin Capistrano::SCM::Git

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

如果您还有其他需要查看的内容,请告诉我...很高兴将其包含在此 post。

感谢您的帮助! 大卫

为了便于阅读,这里是资产模型。我把它放在评论里,看起来很难读...

class Ckeditor::Asset < ActiveRecord::Base
  include ActiveRecord
  include Ckeditor::Orm::ActiveRecord::AssetBase
  include Ckeditor::Backend::CarrierWave
end

这是 ckeditor_picture_uploader 文件。它确实有 "process" 美洲狮抱怨的电话。我目前正在查看资产路径和资产预编译...

class CkeditorPictureUploader < CarrierWave::Uploader::Base
  include Ckeditor::Backend::CarrierWave
  include CarrierWave::MiniMagick

  storage :file

  def store_dir
    "uploads/ckeditor/pictures/#{model.id}"
  end

  process :extract_dimensions

  version :thumb do
    process resize_to_fill: [118, 100]
  end

 version :content do
  process resize_to_limit: [800, 800]
 end

 def extension_white_list
  Ckeditor.image_file_types
 end

结束

这很奇怪,但已解决。

puma一直在抱怨的'process'方法通常定义在carrierwavegem的uploader/processing.rb文件中。

我说正常是因为在我的情况下,事实并非如此。不知何故,我得到了一个格式错误的 processing.rb 文件,它没有包含 'process'(也不是邪恶的双胞胎 'process!')。我绞尽脑汁思考这是怎么发生的,无法真正解释它。

尽管如此,抓取一份完整的文件副本并用它替换我格式错误的副本解决了问题。

看起来有点虎头蛇尾,不是吗?

无论如何,我要感谢@Md.FarhanMemon 和@SachinSingh 花时间回答和提问。