ruby on rails - Can't start unicorn in production - can't convert Pathname into String (TypeError) -
i have rails 3 (spree) application can start in development not production.
if run bundle exec unicorn -c config/unicorn.rb -d -e development works.
however, bundle exec unicorn -c config/unicorn.rb -d -e production, returns with:
master failed start, check stderr log details
here's unicorn.stder.log file:
i, [2012-06-04t17:31:54.497851 #10431] info -- : listening on addr=/tmp/unicorn-uspatriottactical.socket fd=5 i, [2012-06-04t17:31:54.499222 #10431] info -- : refreshing gem list /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require': can't convert pathname string (typeerror) /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:359:in `require_or_load' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:502:in `load_missing_constant' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:192:in `block in const_missing' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `each' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `const_missing' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/bundler/gems/spree_related_products-72cbbfc9ed31/lib/spree_related_products.rb:17:in `block in <class:engine>' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing' /var/rails/uspatriottactical/releases/20120604171150/config/environment.rb:5:in `<top (required)>' config.ru:4:in `require' config.ru:4:in `block in <main>' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize' config.ru:1:in `new' config.ru:1:in `<main>' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `eval' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `block in builder' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `call' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `build_app!' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:136:in `start' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `<top (required)>' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load' /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>' because seems gem issue, here gemfile:
source 'http://rubygems.org' gem 'active_shipping', :git => 'git://github.com/shopify/active_shipping.git' gem 'carrierwave' gem 'jquery-rails' gem 'rails', '~> 3.2.0' gem 'rmagick' gem 'spree', :git => 'git://github.com/spree/spree', :branch => '1-1-stable' gem 'spree_active_shipping', :git => 'git://github.com/spree/spree_active_shipping.git' gem 'spree_flexi_variants', :git => 'git://github.com/jsqu99/spree_flexi_variants.git' gem 'spree_reviews', :git => 'git://github.com/spree/spree_reviews.git' gem 'spree_related_products', :git => 'git://github.com/spree/spree_related_products.git' gem 'spree_shipworks_api', :path => 'spree_shipworks_api' gem 'spree_amazon_fps', :path => 'spree_amazon_fps' # gem 'spree_variant_options', :git => 'git://github.com/citrus/spree_variant_options.git' gem 'spree_videos', :git => 'git://github.com/iloveitaly/spree-videos.git' gem 'spree_gateway', :git => 'git://github.com/spree/spree_gateway.git' gem 'spree_paypal_express', :git => 'git://github.com/spree/spree_paypal_express.git' gem 'remit', :git => 'git://github.com/tylerhunt/remit.git' #gem 'remit', :path => '../remit' gem 'unicorn' # temporary gem 'sqlite3' gem 'execjs' gem 'therubyracer' group :assets gem 'coffee-rails', '~> 3.2.0' gem 'sass-rails', '~> 3.2.0' gem 'uglifier', '>= 1.2.4' end group :console gem 'awesome_print', :require => 'ap' gem 'hirb-unicode' gem 'wirb' end group :development, :test gem 'capybara' gem 'factory_girl_rails' gem 'faker' gem 'mysql2' gem 'pry' gem 'rspec-rails' gem 'sunspot_rails', '~> 1.3.1' gem 'progress_bar', '0.4.0' gem 'sunspot_solr' gem "sunspot_with_kaminari", '~> 0.1' gem 'sqlite3' gem 'debugger' end group :development # gem 'heroku' gem 'pry-rails' end group :production gem 'capistrano' gem 'rvm-capistrano' gem 'mysql2' gem 'sunspot_rails', '~> 1.3.1' gem 'progress_bar', '0.4.0' gem 'sunspot_solr' gem "sunspot_with_kaminari", '~> 0.1' end # used when running on heroku # group :deployment # gem 'foreman' # gem 'pg' # gem 'thin' # end group :test gem 'fakeweb' # pretty printed test output gem 'turn', '~> 0.8.3', :require => false gem 'vcr' end edit: here's unicorn.rb
# see http://unicorn.bogomips.org/unicorn/configurator.html complete documentation. www_dir = "/var/rails/" app_name = "uspatriottactical" # set environment development unless else specified #env = env["rails_env"] || "production" # amount of unicorn workers spin worker_processes 2 # socket bind listen "/tmp/unicorn-#{app_name}.socket" preload_app true # restarts workers hang 30 seconds timeout 30 pid "/tmp/unicorn.#{app_name}.pid" #if env == "production" user 'app_user', 'app_user' # 'user', 'group' working_directory "#{www_dir}#{app_name}/current" shared_path = "#{www_dir}#{app_name}/shared" stderr_path "#{shared_path}/log/unicorn.stderr.log" stdout_path "#{shared_path}/log/unicorn.stdout.log" #end before_fork |server, worker| # following highly recomended rails + "preload_app true" # there's no need master process hold connection if defined?(activerecord::base) activerecord::base.connection.disconnect! end # when sent usr2, unicorn suffix pidfile .oldbin , # start loading new version of (loaded new # version of our app). when new unicorn loaded # begin spawning workers. first worker spawned check # see if .oldbin pidfile exists. if so, means we've booted # new unicorn , need tell old 1 can die. # send quit. # # enables 0 downtime deploys. old_pid = "/var/run/unicorn-#{app_name}.pid.oldbin" if file.exists?(old_pid) && server.pid != old_pid begin process.kill("quit", file.read(old_pid).to_i) rescue errno::enoent, errno::esrch # else did our job end end end after_fork |server, worker| # unicorn master loads app forks off workers - because of way # unix forking works, need make sure aren't using of parent's # sockets, e.g. db connection (since "preload_app true") if defined?(activerecord::base) activerecord::base.establish_connection end # if preload_app true, may want check , # restart other shared sockets/descriptors such memcached, # , redis. tokyocabinet file handles safe reuse # between number of forked children (assuming kernel # correctly implements pread()/pwrite() system calls) end edit: per request /var/rails/uspatriottactical/shared/bundle/ruby/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb
i commented on line 63
require 'pathname' module polyglot @registrations ||= {} # guard against reloading @loaded ||= {} class polyglotloaderror < loaderror; end class nestedloaderror < loaderror def initialize le @le = le end def reraise raise @le end end def self.register(extension, klass) extension = [extension] unless array === extension extension.each{|e| @registrations[e] = klass } end def self.find(file, *options, &block) is_absolute = pathname.new(file).absolute? (is_absolute ? [""] : $:).each{|lib| base = is_absolute ? "" : lib+file::separator # in windows, repeated separator chars have special meaning, avoid adding them matches = dir["#{base}#{file}{,.#{@registrations.keys*',.'}}"] # revisit: should more if more 1 candidate found? $stderr.puts "polyglot: found more 1 candidate #{file}: #{matches*", "}" if matches.size > 1 if path = matches[0] return [ path, @registrations[path.gsub(/.*\./,'')]] end } return nil end def self.load(*a, &b) file = a[0].to_str return if @loaded[file] # check $: changes or file time changes , reload? begin source_file, loader = polyglot.find(file, *a[1..-1], &b) if (loader) begin loader.load(source_file) @loaded[file] = true rescue loaderror => e raise polyglot::nestedloaderror.new(e) end else raise polyglotloaderror.new("failed load #{file} using extensions #{(@registrations.keys+["rb"]).sort*", "}") end end end end module kernel alias polyglot_original_require require def require(*a, &b) polyglot_original_require(*a, &b) # <- line 63 rescue loaderror => load_error begin polyglot.load(*a, &b) rescue polyglot::nestedloaderror => e e.reraise rescue loaderror # raise original exception, possibly missingsourcefile path raise load_error end end end
upgrading ruby 1.9.3 corrects issue.
see github.com/cjheath/polyglot/issues/2 details.
apparently there issue ruby 1.9.1 , 1.9.2 rvm installs.
Comments
Post a Comment