Skip to content

Commit

Permalink
fix: fixes potential issue if machine hostname cannot be determined
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed Feb 24, 2024
1 parent 2e7b36c commit 0fcf778
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/util/health_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def call(env)
private

def root
[200, { "Content-Type" => "text/plain" }, ["#{@name} (pid: #{Process.pid}, host: #{Socket.gethostname})"]]
[200, { "Content-Type" => "text/plain" }, ["#{@name} (pid: #{Process.pid}, host: #{hostname})"]]
end

def ok
Expand All @@ -43,6 +43,12 @@ def metrics
[200, { "Content-Type" => "text/plain" }, [body]]
end

def hostname
Socket.gethostname
rescue StandardError
"unknown-hostname"
end

class << self

def run(default_port: 9090, **options)
Expand Down

0 comments on commit 0fcf778

Please sign in to comment.