Skip to content

Commit

Permalink
Moved EM::run to really high up the stack so it's easier to start oth…
Browse files Browse the repository at this point in the history
…er evented services from framework initializers (like environment.rb under rails)
  • Loading branch information
raggi committed Jul 31, 2008
1 parent 1e8d503 commit 6cad30e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 2 additions & 5 deletions lib/thin/backends/base.rb
Expand Up @@ -45,11 +45,8 @@ def initialize
# Start the backend and connect it.
def start
@stopping = false

EventMachine.run do
connect
@running = true
end
connect
@running = true
end

# Stop of the backend from accepting new connections.
Expand Down
22 changes: 14 additions & 8 deletions lib/thin/runner.rb
Expand Up @@ -135,14 +135,20 @@ def parse!
# Parse the current shell arguments and run the command.
# Exits on error.
def run!
if self.class.commands.include?(@command)
run_command
elsif @command.nil?
puts "Command required"
puts @parser
exit 1
else
abort "Invalid command: #{@command}"
# jftucker at gmail dot com - move EM::run to a muuuch higher place in
# the stack, for the purposes of starting up other evented services
# without having to break into framework / server code to hook a timely
# startup.
EventMachine.run do
if self.class.commands.include?(@command)
run_command
elsif @command.nil?
puts "Command required"
puts @parser
exit 1
else
abort "Invalid command: #{@command}"
end
end
end

Expand Down

0 comments on commit 6cad30e

Please sign in to comment.