Skip to content

Add unicorn configuration #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
app_path = File.expand_path(File.dirname(__FILE__) + '/..')

worker_processes 2

listen 8080, tcp_nopush: true

working_directory app_path

pid app_path + '/tmp/unicorn.pid'

stderr_path '/var/www/timeoverflow/shared/log/unicorn.err.log'
stdout_path '/var/www/timeoverflow/shared/log/unicorn.std.log'

# Load the app up before forking
# Combine Ruby 2.0.0+ with "preload_app true" for memory savings
preload_app true

before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|
# the following is *required* for Rails + "preload_app true"
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end