Class: Daps::Server
- Inherits:
-
Object
- Object
- Daps::Server
- Defined in:
- lib/daps/server.rb
Defined Under Namespace
Modules: Pipe Classes: ArchiveStreamer
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(dir, token, port) ⇒ Server
constructor
A new instance of Server.
- #start! ⇒ Object
Constructor Details
#initialize(dir, token, port) ⇒ Server
Returns a new instance of Server.
3 4 5 |
# File 'lib/daps/server.rb', line 3 def initialize(dir, token, port) @dir, @token, @port = File.(dir), token, port.to_i end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 |
# File 'lib/daps/server.rb', line 18 def call(env) env['daps.token'] = @token env['daps.dir'] = @dir ArchiveStreamer.call(env) end |
#start! ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/daps/server.rb', line 7 def start! Dir.chdir(@dir) @port = rand(5000) + 5000 if @port == 0 @token ||= Digest::SHA1.hexdigest([Time.now, rand(1<<100)].join('--')) puts "URI: daps://#{`hostname`.strip}:#{@port}/#{@token}" Rack::Handler::Thin.run(self, :Port => @port) { |s| s.silent = true } end |