def connectDaemon
unless @authKey
error('missing_auth_key', "You must set an authentication key in the configuration file. Create a file
named .taskjugglerrc or taskjuggler.rc that contains at least the following
lines. Replace 'your_secret_key' with some random character sequence.
_global:
authKey: your_secret_key
"
)
end
uri = "druby://#{@host}:#{@port}"
if @port == 0
begin
uri = File.read(@uriFile).chomp
rescue
error('tjc_port_0',
'The server port is configured to be 0, but no ' +
".tj3d.uri file can be found: #{$!}")
end
end
debug('', "DRb URI determined as #{uri}")
$SAFE = 1 unless @unsafeMode
DRb.install_acl(ACL.new(%w[ deny all
allow 127.0.0.1 ]))
DRb.start_service('druby://127.0.0.1:0')
debug('', 'DRb service started')
broker = nil
begin
broker = DRbObject.new_with_uri(uri)
if (check = broker.apiVersion(@authKey, 1)) < 0
error('tjc_too_old',
'This client is too old for the server. Please ' +
'upgrade to a more recent version of the software.')
elsif check == 0
error('tjc_auth_fail',
'Authentication failed. Please check your authentication ' +
'key to match the server key.')
end
debug('', "Connection with report broker on #{uri} established")
rescue => e
if e.is_a?(TjRuntimeError)
raise TjRuntimeError, $!
end
error('tjc_srv_not_responding',
"TaskJuggler server (tj3d) on URI '#{uri}' is not " +
"responding:\n#{$!}")
end
broker
end