puma.rb 696 B

1234567891011121314151617181920212223242526272829303132
  1. # frozen_string_literal: true
  2. require_relative 'auto_tune'
  3. require 'etc'
  4. require 'sequel'
  5. # FWBM only... use the puma_auto_tune gem in production!
  6. num_workers, num_threads = auto_tune
  7. num_threads = [num_threads, 32].min
  8. before_fork do
  9. Sequel::DATABASES.each(&:disconnect)
  10. end
  11. if RUBY_PLATFORM == 'java'
  12. num_threads = 512
  13. num_workers = 0
  14. end
  15. workers num_workers
  16. threads num_threads, num_threads
  17. # Use the `preload_app!` method when specifying a `workers` number.
  18. # This directive tells Puma to first boot the application and load code
  19. # before forking the application. This takes advantage of Copy On Write
  20. # process behavior so workers use less memory.
  21. #
  22. preload_app!