Created
February 6, 2010 17:02
-
-
Save maccman/296810 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# using Raw TCP sockets and thin | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'thin' | |
module Rack | |
module Adapter | |
def self.guess(*args) | |
return :taskforce | |
end | |
def self.for(name, options = {}) | |
proc {} | |
end | |
end | |
end | |
class CustomConnection < Taskforce::Connection | |
attr_accessor :backend | |
def app=(d); end | |
def threaded=(d); end | |
def response=(d); end | |
def request=(d); end | |
def can_persist!; end | |
def comm_inactivity_timeout=(d); end | |
def close_connection | |
trace "close_connection" | |
super | |
end | |
def close_connection_after_writing | |
trace "close_connection_after_writing" | |
super | |
end | |
def can_persist? | |
true | |
end | |
def persistent? | |
true | |
end | |
def threaded? | |
false | |
end | |
end | |
class CustomServer < Thin::Backends::TcpServer | |
include Thin::Logging | |
def connect | |
@signature = EventMachine.start_server( | |
@host, @port, | |
CustomConnection, | |
&method(:initialize_connection) | |
) | |
trace "Setting up poller timer" | |
EventMachine::add_periodic_timer(2, Taskforce::Sync::Poller) | |
end | |
end | |
silence_warnings { | |
Thin::Logging = Taskforce::Logging | |
Thin::Backends::TcpServer = CustomServer | |
} | |
Thin::Runner.new(ARGV).run! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment