lib/jerbil/service.rb in jerbil-1.3.3 vs lib/jerbil/service.rb in jerbil-1.4.5
- old
+ new
@@ -30,20 +30,30 @@
# create a new service record object
#
# Note that the callback parameters do not really need to be considered
# if you are using {JerbilService::Base}
#
+ # Warning - if your hostname is not fully qualified this may not work as expected
+ # if you DNS server does not provide expected reverse lookup. Consider using
+ # `hostname -f` although *nix dependent.
+ #
# @param [Symbol] name identifying the service - needs to match /etc/services
# or create fails with the exception InvalidService
# @param [Symbol] env identify the service's environment. Allows multiple
# services to operate for development etc
# @param [Symbol] verify_callback being the name of the method to call to check
# that the service is working
# @param [Symbol] stop_callback as above but the method stops the service
# @return [ServiceRecord] of course
# @raise [InvalidService] if the service is not registered through /etc/services
def initialize(name, env, verify_callback=:verify_callback, stop_callback=nil)
+
+ # gethostname may npt provide the fqdn
@host = Socket.gethostname
+ if @host.split('.').length == 1 then
+ # no domain name
+ @host = Socket.gethostbyname(@host).first
+ end
@name = name
begin
@port = Socket.getservbyname(@name.to_s)
rescue
raise InvalidService, "No service registered as: #{name}"
\ No newline at end of file