Skip to content

Commit acc719d

Browse files
committed
Add unicorn configuration
1 parent 94a4ad8 commit acc719d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

config/unicorn.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
app_path = File.expand_path(File.dirname(__FILE__) + '/..')
2+
3+
worker_processes 2
4+
5+
listen listen 8080, tcp_nopush: true
6+
7+
working_directory app_path
8+
9+
pid app_path + '/tmp/unicorn.pid'
10+
11+
stderr_path '/var/www/timeoverflow/shared/log/unicorn.log'
12+
stdout_path '/var/www/timeoverflow/shared/log/unicorn.log'
13+
14+
# Load the app up before forking
15+
# Combine Ruby 2.0.0+ with "preload_app true" for memory savings
16+
preload_app true
17+
18+
before_fork do |server, worker|
19+
# the following is highly recomended for Rails + "preload_app true"
20+
# as there's no need for the master process to hold a connection
21+
defined?(ActiveRecord::Base) and
22+
ActiveRecord::Base.connection.disconnect!
23+
end
24+
25+
after_fork do |server, worker|
26+
# the following is *required* for Rails + "preload_app true"
27+
defined?(ActiveRecord::Base) and
28+
ActiveRecord::Base.establish_connection
29+
end

0 commit comments

Comments
 (0)