mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: avoid shelling to get hostname aggressively
Previously we had many places in the app that called `hostname` to get hostname of a server. This commit replaces the pattern in 2 ways 1. We cache the result in `Discourse.os_hostname` so it is only ever called once 2. We prefer to use Socket.gethostname which avoids making a shell command This improves performance as we are not spawning hostname processes throughout the app lifetime
This commit is contained in:
@@ -128,7 +128,7 @@ begin
|
||||
[['critical', 8], ['default', 4], ['low', 2], ['ultra_low', 1]].each do |queue_name, weight|
|
||||
custom_queue_hostname = ENV["UNICORN_SIDEKIQ_#{queue_name.upcase}_QUEUE_HOSTNAME"]
|
||||
|
||||
if !custom_queue_hostname || custom_queue_hostname.split(',').include?(`hostname`.strip)
|
||||
if !custom_queue_hostname || custom_queue_hostname.split(',').include?(Discourse.os_hostname)
|
||||
options << "-q"
|
||||
options << "#{queue_name},#{weight}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user