puma.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. worker_count = Integer(ENV['WEB_CONCURRENCY'] || 0)
  3. workers worker_count
  4. threads_count_min = Integer(ENV['MIN_THREADS'] || 5)
  5. threads_count_max = Integer(ENV['MAX_THREADS'] || 30)
  6. threads threads_count_min, threads_count_max
  7. environment ENV.fetch('RAILS_ENV', 'development')
  8. preload_app!
  9. # Teach pumactl to use 'SIGWINCH' instead of 'SIGINFO', because the latter is not available on Linux.
  10. if defined?(Puma::ControlCLI)
  11. # Suppress const redefinition warning (can't use silcence_warnings from Rails here).
  12. old_verbose = $VERBOSE
  13. $VERBOSE = nil
  14. Puma::ControlCLI::CMD_PATH_SIG_MAP = Puma::ControlCLI::CMD_PATH_SIG_MAP.merge({ 'info' => 'SIGWINCH' }).freeze
  15. $VERBOSE = old_verbose
  16. end
  17. begin
  18. on_booted do
  19. AppVersion.start_maintenance_thread(process_name: 'puma')
  20. Zammad::ProcessDebug.install_thread_status_handler
  21. end
  22. rescue NoMethodError
  23. # Workaround for https://github.com/puma/puma/issues/3356, can be removed after this is
  24. # solved and a new puma version is released where 'pumactl status' works again.
  25. end
  26. if worker_count.positive?
  27. on_worker_boot do
  28. ActiveRecord::Base.establish_connection
  29. Zammad::ProcessDebug.install_thread_status_handler
  30. end
  31. end