@@ -136,9 +136,11 @@ def run
136136 def on_start
137137 puts '** SequenceServer is ready.'
138138 puts " Go to #{ server_url } in your browser and start BLASTing!"
139- puts ' To share your setup, please try one of the following: '
140- puts " - http://#{ ip_address } :#{ config [ :port ] } "
141- puts " - http://#{ hostname } :#{ config [ :port ] } " if hostname
139+ if ip_address
140+ puts ' To share your setup, please try one of the following: '
141+ puts " - http://#{ ip_address } :#{ config [ :port ] } "
142+ puts " - http://#{ hostname } :#{ config [ :port ] } " if hostname
143+ end
142144 puts ' Press CTRL+C to quit.'
143145 open_in_browser ( server_url )
144146 end
@@ -253,13 +255,14 @@ def server_url
253255 "http://#{ host } :#{ config [ :port ] } "
254256 end
255257
256- # Returns a local ip adress
258+ # Returns a local ip adress.
257259 def ip_address
258- Socket . ip_address_list . find { |ai | ai . ipv4? && !ai . ipv4_loopback? } . ip_address
260+ addrinfo = Socket . ip_address_list . find { |ai | ai . ipv4? && !ai . ipv4_loopback? }
261+ addrinfo . ip_address if addrinfo
259262 end
260263
261- # Returns machine's hostname based on the local ip;
262- # If hostname cannot be determined then print nothing
264+ # Returns machine's hostname based on the local ip. If hostname cannot be
265+ # determined returns nil.
263266 def hostname
264267 Resolv . getname ( ip_address ) rescue nil
265268 end
0 commit comments