t_anjan

puma.rb

Aug 17th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.88 KB | None | 0 0
  1. #!/usr/bin/env puma
  2.  
  3. environment 'staging'
  4.  
  5. pidfile "/myapp/tmp/pids_puma.pid"
  6. state_path "/myapp/tmp/pids_puma.state"
  7. stdout_redirect '/myapp/log/puma_access.log', '/myapp/log/puma_error.log', true
  8.  
  9. threads 2, 8
  10.  
  11. bind 'tcp://0.0.0.0:3000'
  12.  
  13. workers 2
  14.  
  15. prune_bundler
  16.  
  17. on_restart do
  18.   puts 'Refreshing Gemfile'
  19.   ENV['BUNDLE_GEMFILE'] = '/myapp/Gemfile'
  20. end
  21.  
  22. on_worker_boot do |worker_index|
  23.   # write worker pid
  24.   pid_filename = "/myapp/tmp/pids_puma_worker_#{worker_index}.pid"
  25.   File.open(pid_filename, 'w') { |f| f.puts Process.pid }
  26.   begin
  27.     # Re-open appenders after forking the process
  28.     SemanticLogger.reopen if defined?( SemanticLogger )
  29.   rescue Exception => e
  30.     puts "Error trying to reopen log, probably because the SemanticLogger gem is not used in this project: #{e.message}"
  31.   end
  32. end
  33.  
  34. activate_control_app 'unix:///myapp/tmp/sockets_pumactl.sock'
Add Comment
Please, Sign In to add comment