module TaskJuggler::ProcessIntercomIface

Public Instance Methods

connect(authKey, stdout, stderr, stdin, silent) click to toggle source
# File lib/taskjuggler/daemon/ProcessIntercom.rb, line 53
def connect(authKey, stdout, stderr, stdin, silent)
  return false unless @server.checkKey(authKey, 'connect')

  trap { @server.connect(stdout, stderr, stdin, silent) }
end
disconnect(authKey) click to toggle source
# File lib/taskjuggler/daemon/ProcessIntercom.rb, line 59
def disconnect(authKey)
  return false unless @server.checkKey(authKey, 'disconnect')

  trap { @server.disconnect }
end
terminate(authKey) click to toggle source
# File lib/taskjuggler/daemon/ProcessIntercom.rb, line 47
def terminate(authKey)
  return false unless @server.checkKey(authKey, 'terminate')

  trap { @server.terminate }
end
trap() { || ... } click to toggle source

This function catches all unhandled exceptions in the passed block.

# File lib/taskjuggler/daemon/ProcessIntercom.rb, line 25
def trap
  begin
    MessageHandlerInstance.instance.trapSetup = true
    res = yield
    MessageHandlerInstance.instance.trapSetup = false
    res
  rescue => e
    # Any exception here is a fatal error. We try hard to terminate the DRb
    # thread and then exit the program.
    begin
      fatal('pi_crash_trap', "#{e}\n#{e.backtrace.join("\n")}\n\n" +
            "#{'*' * 79}\nYou have triggered a bug in " +
            "#{AppConfig.softwareName} version #{AppConfig.version}!\n" +
            "Please see the user manual on how to get this bug fixed!\n" +
            "#{'*' * 79}\n")
    rescue RuntimeError
      @server.terminate
      return false
    end
  end
end