ruby on rails - uninitialized constant ActiveRecord (NameError) wiith Dokku + nginx + unicorn -


i run rails app on digitalocean using dokku + nginx + postgresql. deployed app running using webrick default server , want migrate unicorn.

gemfile

group :production   gem 'pg'   gem 'unicorn' end 

i have used heroku configs unicorn

procfile

web: bundle exec unicorn -p $port -c ./config/unicorn.rb 

config/unicorn.rb

worker_processes integer(env["web_concurrency"] || 3) timeout 15 preload_app true  before_fork |server, worker|   signal.trap 'term'     puts 'unicorn master intercepting term , sending myself quit instead'     process.kill 'quit', process.pid   end    defined?(activerecord::base) ,     activerecord::base.connection.disconnect! end  after_fork |server, worker|   signal.trap 'term'     puts 'unicorn worker intercepting term , doing nothing. wait master send quit'   end    defined?(activerecord::base) ,     activerecord::base.establish_connection end 

and how log like

root@oktobtest:~# dokku logs oktob i, [2015-04-25t18:30:29.195191 #13]  info -- : refreshing gem list config.ru:4:in `block in <main>': uninitialized constant activerecord (nameerror)     /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'     /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'     config.ru:1:in `new'     config.ru:1:in `<main>'     /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'     /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'     /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'     /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'     /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:137:in `start'     /app/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'     /app/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'     /app/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<main>' 

when run docker ps command see postgresql process , there no process rails server.

root@oktobtest:~# docker ps container id        image                     command                created             status              ports                     names fbdbb516b19c        postgresql/oktob:latest   "/usr/bin/start_pgsq   2 hours ago         2 hours          0.0.0.0:49153->5432/tcp   elegant_ardinghelli 

i asked question on dokku github page , got answer

so adding active_record gem config/unicorn.rb solve issue as:

require 'rubygems' require 'active_record'  worker_processes integer(env["web_concurrency"] || 3) timeout 15 preload_app true  before_fork |server, worker|   signal.trap 'term'     puts 'unicorn master intercepting term , sending myself quit instead'     process.kill 'quit', process.pid   end    defined?(activerecord::base) ,     activerecord::base.connection.disconnect! end  after_fork |server, worker|   signal.trap 'term'     puts 'unicorn worker intercepting term , doing nothing. wait master send quit'   end    defined?(activerecord::base) ,     activerecord::base.establish_connection end 

and result

using docker ps

container id image command created status ports names 4a43ac670998 dokku/oktob:latest "/start web" 12 minutes ago 12 minutes grave_yonath fbdbb516b19c postgresql/oktob:latest "/usr/bin/start_pgsq 6 days ago 6 days 0.0.0.0:49153->5432/tcp elegant_ardinghelli

using htop

enter image description here


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -