fix: fixes potential issue if machine hostname cannot be determined

This commit is contained in:
Adam Cooke
2024-02-24 11:03:04 +00:00
parent 2e7b36c1be
commit 0fcf778a51
+7 -1
View File
@@ -26,7 +26,7 @@ class HealthServer
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
@@ -43,6 +43,12 @@ class HealthServer
[200, { "Content-Type" => "text/plain" }, [body]]
end
def hostname
Socket.gethostname
rescue StandardError
"unknown-hostname"
end
class << self
def run(default_port: 9090, **options)