Sha256: 3948afd38f2523aa76c8d8062365c6c5dabd348b0e78f554ffaf9fba04f6309d
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
#!/usr/bin/env ruby # # An example application using our patched Thin and EventMachine. You # can obtain these from: # # https://github.com/stripe/thin.git, and # https://github.com/stripe/eventmachine.git require 'rubygems' require 'einhorn' # Make sure we're using the patched versions. gem 'thin', '1.3.2.stripe.0' gem 'eventmachine', '1.0.0.beta.4.stripe.0' require 'thin' class App def initialize(id) @id = id end def call(env) return [200, {}, "[#{$$}] From server instance #{@id}: Got your request!\n"] end end def einhorn_main puts "Called with #{ARGV.inspect}" if ARGV.length == 0 raise "Need to call with at least one argument. Try running 'einhorn #{$0} srv:127.0.0.1:5000,r,n srv:127.0.0.1:5001,r,n' and then running 'curl 127.0.0.1:5000' or 'curl 127.0.0.1:5001'" end Einhorn::Worker.graceful_shutdown do puts "#{$$} is now exiting..." exit(0) end Einhorn::Worker.ack! EventMachine.run do ARGV.each_with_index do |arg, i| sock = Integer(arg) srv = Thin::Server.new(sock, App.new(i), :reuse => true) srv.start end end end if $0 == __FILE__ einhorn_main end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
einhorn-0.3.2 | example/thin_example |
einhorn-0.3.1 | example/thin_example |
einhorn-0.3.0 | example/thin_example |