Commit ca96fff
Changed files (3)
config/unicorn.rb
@@ -0,0 +1,26 @@
+worker_processes 8
+timeout 15
+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
+
+ if defined?(ActiveRecord::Base)
+ ActiveRecord::Base.connection.disconnect!
+ Rails.logger.info('Disconnected from ActiveRecord')
+ end
+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
+
+ if defined?(ActiveRecord::Base)
+ ActiveRecord::Base.establish_connection
+ Rails.logger.info('Connected to ActiveRecord')
+ end
+end
Procfile
@@ -1,1 +1,1 @@
-web: rails s -b 0.0.0.0
+web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
Vagrantfile
@@ -8,7 +8,7 @@ Vagrant.configure("2") do |config|
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
#config.vm.network :forwarded_port, guest: 80, host: 8080
- config.vm.network :forwarded_port, guest: 3000, host: 3000
+ config.vm.network :forwarded_port, guest: 5000, host: 3000
config.vm.provision :shell, :path => 'bin/bootstrap.sh'
config.ssh.forward_agent = true