puma.rb 661 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. before_fork do
  8. Sequel::DATABASES.each(&:disconnect)
  9. end
  10. if RUBY_PLATFORM == 'java'
  11. num_threads = 512
  12. num_workers = 0
  13. end
  14. workers num_workers
  15. threads num_threads, num_threads
  16. # Use the `preload_app!` method when specifying a `workers` number.
  17. # This directive tells Puma to first boot the application and load code
  18. # before forking the application. This takes advantage of Copy On Write
  19. # process behavior so workers use less memory.
  20. #
  21. preload_app!