def handle_signal(signal)
      info "Got signal #{signal}"
      case signal
      when 'TERM', 'INT', 'SHUTDOWN' # shutdown is an internal command
        info 'Shutting down...'
        # EM.stop if EventMachine.reactor_running?
        @plugins.stop
        @supervisor.shutdown
        true
      when 'TTIN'
        Thread.list.each do |thread|
          warn "Thread #{thread.object_id.to_s(36)} #{thread['label']}"
          if thread.backtrace
            warn thread.backtrace.join("\n")
          else
            warn 'no backtrace available'
          end
        end
        false
      end
    end
def handle_signal(signal)
      info "Got signal #{signal}"
      case signal
      when 'TERM', 'INT', 'SHUTDOWN' # shutdown is an internal command
        info 'Shutting down...'
        # EM.stop if EventMachine.reactor_running?
        @plugins.stop
        @supervisor.shutdown
        true
      when 'TTIN'
        Thread.list.each do |thread|
          warn "Thread #{thread.object_id.to_s(36)} #{thread['label']}"
          if thread.backtrace
            warn thread.backtrace.join("\n")
          else
            warn 'no backtrace available'
          end
        end
        false
      end
    end
EM.epoll
  Thread.new { EventMachine.run } unless EventMachine.reactor_running?
  sleep 0.01 until EventMachine.reactor_running?
 end