lib/orats/templates/includes/new/rails/config/puma.rb in orats-0.8.1 vs lib/orats/templates/includes/new/rails/config/puma.rb in orats-0.9.0

- old
+ new

@@ -1,19 +1,29 @@ environment ENV['RAILS_ENV'] -threads ENV['PUMA_THREADS_MIN'].to_i, ENV['PUMA_THREADS_MAX'].to_i -workers ENV['PUMA_WORKERS'].to_i +threads ENV['THREADS_MIN'].to_i, ENV['THREADS_MAX'].to_i +workers ENV['WORKERS'].to_i -pidfile "tmp/puma.pid" +if ENV['RAILS_ENV'] == 'development' || ENV['RAILS_ENV'] == 'test' + bind 'tcp://0.0.0.0:3000' +else + bind "unix:#{ENV['RUN_STATE_PATH']}/app_name" +end -# https://github.com/puma/puma/blob/master/examples/config.rb#L125 -prune_bundler +pidfile "#{ENV['RUN_STATE_PATH']}/app_name.pid" -restart_command 'bundle exec bin/puma' +worker_timeout 30 +stdout_redirect "#{ENV['LOG_PATH']}/app_name.stdout.log", + "#{ENV['LOG_PATH']}/app_name.stderr.log" + +preload_app! + +restart_command 'bundle exec puma' + on_worker_boot do - require 'active_record' + defined?(ActiveRecord::Base) and + ActiveRecord::Base.connection.disconnect! - config_path = File.expand_path('../database.yml', __FILE__) - ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished - ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'] || YAML.load_file(config_path)[ENV['RAILS_ENV']]) + defined?(ActiveRecord::Base) and + ActiveRecord::Base.establish_connection end