From a64913eafbee3501a677b1232470838a4ad0fc65 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 5 Jun 2009 22:16:47 -0700 Subject: Unicorn::App::Inetd: reinventing Unix, poorly :) This includes an example of tunneling the git protocol inside a TE:chunked HTTP request. The example is unfortunately contrived in that it relies on the custom examples/cat-chunk-proxy.rb script in the client. My initial wish was to have a generic tool like curl(1) operate like this: cat > ~/bin/cat-chunk-proxy.sh < e + end + s.write("0\r\n\r\n") +} + +output = fork { + $0 = "output #$0" + + c = Unicorn::ChunkedReader.new + c.reopen(s, body) + begin + loop { $stdout.write(c.readpartial(16384, buf)) } + rescue EOFError,Errno::EPIPE,Errno::EBADF,Errno::EINVAL => e + end +} + +2.times { + pid, status = Process.waitpid2 + $stderr.write("reaped: #{status.inspect}\n") unless status.success? +} diff --git a/examples/git.ru b/examples/git.ru new file mode 100644 index 0000000..3762d3d --- /dev/null +++ b/examples/git.ru @@ -0,0 +1,9 @@ +#\-E none +require 'unicorn/app/inetd' + +use Rack::Lint +use Rack::Chunked +# run Unicorn::App::Inetd.new('tee', '/tmp/tee.out') +run Unicorn::App::Inetd.new( + *%w(git daemon --verbose --inetd --export-all --base-path=/home/ew/unicorn) +) -- cgit v1.2.3-24-ge0c7