Sha256: 097e07214454d9b72a78b5300e2ba3e5633b253b9e2f58878e3bc1bbb2bc1902

Contents?: true

Size: 585 Bytes

Versions: 2

Compression:

Stored size: 585 Bytes

Contents

require 'tork/client'

module Tork
class Server

  def initialize
    trap(:SIGTERM){ quit }
  end

  def quit
    Thread.exit # kill Client::Receiver in loop()
  end

  def loop
    @client = Client::Transmitter.new(STDOUT.dup)
    STDOUT.reopen(STDERR).sync = true

    Client::Receiver.new(STDIN) do |command|
      if command.first != __method__ # prevent loops
        @command = command
        begin
          __send__(*command)
        rescue => error
          warn "#{$0}: #{error}"
          warn error.backtrace.join("\n")
        end
      end
    end.join
  end

end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tork-18.2.4 lib/tork/server.rb
tork-18.2.3 lib/tork/server.rb