Module: ServerEngine::ClassMethods

Included in:
ServerEngine
Defined in:
lib/serverengine/utils.rb

Instance Method Summary collapse

Instance Method Details

#dump_uncaught_error(e) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/serverengine/utils.rb', line 28

def dump_uncaught_error(e)
  STDERR.write "Unexpected error #{e}\n"
  e.backtrace.each {|bt|
    STDERR.write "  #{bt}\n"
  }
  nil
end

#format_join_status(code) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/serverengine/utils.rb', line 43

def format_join_status(code)
  case code
  when Process::Status
    if code.signaled?
      "signal #{format_signal_name(code.termsig)}"
    else
      "status #{code.exitstatus}"
    end
  when Exception
    "exception #{code}"
  when nil
    "unknown reason"
  end
end

#format_signal_name(n) ⇒ Object



36
37
38
39
40
41
# File 'lib/serverengine/utils.rb', line 36

def format_signal_name(n)
  Signal.list.each_pair {|k,v|
    return "SIG#{k}" if n == v
  }
  return n
end