Friday, 2 August 2013

rails and unicorn on localhost

#-------------------------------------------------
#Gem file
#-------------------------------------------------
gem 'unicorn'
#-------------------------------------------------
#Procfile in root directory (for heroku):
#-------------------------------------------------
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
#-------------------------------------------------
#./config/unicorn.rb file
#-------------------------------------------------
worker_processes 1
timeout 30
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
#make alias in ~/.profile start the server
# alias rails_u="unicorn_rails --config-file config/unicorn.rb -p 3000"
#I, [2013-08-02T21:54:02.553577 #57526] INFO -- : Refreshing Gem list
#I, [2013-08-02T21:54:10.570714 #57526] INFO -- : listening on addr=0.0.0.0:3000 fd=9
#I, [2013-08-02T21:54:10.617927 #57526] INFO -- : master process ready
#I, [2013-08-02T21:54:10.627250 #57538] INFO -- : worker=0 ready
view raw gistfile1.rb hosted with ❤ by GitHub

No comments:

Post a Comment