def run_till_terminated_or_interrupted(signals, wait_interval = 60)
      @stop_server = false
      @stop_server_mu = Mutex.new
      @stop_server_cv = ConditionVariable.new

      @stop_server_thread = Thread.new do
        loop do
          break if @stop_server
          @stop_server_mu.synchronize do
            @stop_server_cv.wait(@stop_server_mu, wait_interval)
          end
        end

        # stop is surrounded by mutex, should handle multiple calls to stop
        #   correctly
        stop
      end

      valid_signals = Signal.list

      # register signal handlers
      signals.each do |sig|
        # input validation
        if sig.class == String
          sig.upcase!
          if sig.start_with?('SIG')
            # cut out the SIG prefix to see if valid signal
            sig = sig[3..-1]
          end
        end

        # register signal traps for all valid signals
        if valid_signals.value?(sig) || valid_signals.key?(sig)
          Signal.trap(sig) do
            @stop_server = true
            @stop_server_cv.broadcast
          end
        else
          fail "#{sig} not a valid signal"
        end
      end

      run

      @stop_server_thread.join
    end
def run_till_terminated_or_interrupted(signals, wait_interval = 60)
      @stop_server = false
      @stop_server_mu = Mutex.new
      @stop_server_cv = ConditionVariable.new

      @stop_server_thread = Thread.new do
        loop do
          break if @stop_server
          @stop_server_mu.synchronize do
            @stop_server_cv.wait(@stop_server_mu, wait_interval)
          end
        end

        # stop is surrounded by mutex, should handle multiple calls to stop
        #   correctly
        stop
      end

      valid_signals = Signal.list

      # register signal handlers
      signals.each do |sig|
        # input validation
        if sig.class == String
          sig.upcase!
          if sig.start_with?('SIG')
            # cut out the SIG prefix to see if valid signal
            sig = sig[3..-1]
          end
        end

        # register signal traps for all valid signals
        if valid_signals.value?(sig) || valid_signals.key?(sig)
          Signal.trap(sig) do
            @stop_server = true
            @stop_server_cv.broadcast
          end
        else
          fail "#{sig} not a valid signal"
        end
      end

      run

      @stop_server_thread.join
    end
runs the server with signal handlers
 @param signals
     List of String, Integer or both representing signals that the user
     would like to send to the server for graceful shutdown
 @param wait_interval (optional)
     Integer seconds that user would like stop_server_thread to poll
     stop_server