Skip to content

Instantly share code, notes, and snippets.

@dphilla
Last active January 15, 2021 00:24
Show Gist options
  • Save dphilla/39df8575ea742b3ab683f49ae53b8b6c to your computer and use it in GitHub Desktop.
Save dphilla/39df8575ea742b3ab683f49ae53b8b6c to your computer and use it in GitHub Desktop.
basic puma.rb
# basic mina puma.rb
# Change to match your CPU core count
workers 1 # note this will be the number of app instances running on the machine!
# Min and Max threads per worker
threads 0, 5
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}"
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
# Set up socket location
bind "unix:///home/mina/app/shared/tmp/sockets/puma.sock"
# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
# Set master PID and state locations
pidfile "/home/mina/app/shared/tmp/pids/puma.pid"
state_path "/home/mina/app/shared/tmp/sockets/puma.state"
directory "/home/mina/app/current"
activate_control_app "unix:#{shared_dir}/tmp/sockets/pumactl.sock"
on_worker_boot do
require "active_record"
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
end
# prune_bundler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment