Module: TaskJuggler::ProcessIntercomIface

Includes:
MessageHandler
Included in:
ProjectServerIface, ReportServerIface
Defined in:
lib/taskjuggler/daemon/ProcessIntercom.rb

Instance Method Summary collapse

Methods included from MessageHandler

#critical, #debug, #error, #fatal, #info, #warning

Instance Method Details

#connect(authKey, stdout, stderr, stdin, silent) ⇒ Object



53
54
55
56
57
# 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) ⇒ Object



59
60
61
62
63
# File 'lib/taskjuggler/daemon/ProcessIntercom.rb', line 59

def disconnect(authKey)
  return false unless @server.checkKey(authKey, 'disconnect')

  trap { @server.disconnect }
end

#terminate(authKey) ⇒ Object



47
48
49
50
51
# File 'lib/taskjuggler/daemon/ProcessIntercom.rb', line 47

def terminate(authKey)
  return false unless @server.checkKey(authKey, 'terminate')

  trap { @server.terminate }
end

#trapObject

This function catches all unhandled exceptions in the passed block.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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