Skip to content

Instantly share code, notes, and snippets.

@caarlos0
Last active December 25, 2015 21:29
Show Gist options
  • Save caarlos0/7042599 to your computer and use it in GitHub Desktop.
Save caarlos0/7042599 to your computer and use it in GitHub Desktop.
Config that I'm using right now with Puma + nginx
upstream puma {
server unix://tmp/wealcash.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name wealcash.com;
root /var/www/wealcash/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
bind "unix:///tmp/wealcash.sock"
pidfile "/tmp/puma.pid"
preload_app!
min_threads = Integer(ENV['MIN_THREADS'] || 2)
max_threads = Integer(ENV['MAX_THREADS'] || 16)
threads min_threads, max_threads
workers Integer(ENV['WORKER_COUNT'] || 2)
on_worker_boot do
ActiveSupport.on_load(:active_record) do
config = Rails.application.config.database_configuration[Rails.env]
config['reaping_frequency'] = ENV['DB_REAP_FREQ'] || 10 # seconds
config['pool'] = ENV['DB_POOL'] || 5
ActiveRecord::Base.establish_connection(config)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment