lib/envoy/client/channel.rb in envoy-proxy-0.2.0 vs lib/envoy/client/channel.rb in envoy-proxy-0.2.2

- old
+ new

@@ -10,10 +10,11 @@ @buffer = "" super() end def connection_completed + @client.log TRACE, "connected to upstream service for stream #{@id}" @tried_starting = nil send_data @buffer, true @buffer = nil end @@ -24,32 +25,35 @@ @buffer << data end end def receive_data data + @client.log TRACE, "#{data.length} bytes of data send on stream #{@id}" @client.send_object :stream, @id, data end def reconnect + @client.log TRACE, "reconnecting to upstream service for stream #{@id}" super @client.options[:local_host], @client.options[:local_port] end def unbind e if e == Errno::ECONNREFUSED + @client.log TRACE, "couldn't connect to upstream service for stream #{@id}" if @tried_starting if Time.now > @tried_starting + @client.options[:delay] - @client.log "Service isn't running, but starting it didn't really work out." + @client.log ERROR, "Service isn't running, but starting it didn't really work out." @client.send_object :close, @id, 502 @tried_starting = false else EM.add_timer 0.1 do reconnect end end elsif cmd = @client.options[:command] cmd = cmd % @client.options - @client.log "Service doesn't seem to be running. Trying to start it now..." + @client.log INFO, "Service doesn't seem to be running. Trying to start it now..." @tried_starting = Time.now p @client.options[:dir] Dir.chdir File.expand_path(@client.options[:dir]) do fork do ENV.delete("GEM_HOME") @@ -62,11 +66,12 @@ EM.add_timer 0.1 do reconnect end end elsif e - @client.log e.inspect + @client.log ERROR, e.inspect else + @client.log TRACE, "upstream service closed stream #{@id}" @client.send_object :close, @id end end end