Skip to content
Browse files

After created job, try to distribute work units asynchronously, and r…

…eturn as soon as possible to client. By this way, when distribution fail or take too long, client request won't get affected.
  • Loading branch information...
1 parent cf842f9 commit 93276abae788861e4d027aff4de3e9fa48f0df25 @felipecvo felipecvo committed
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/cloud_crowd/server.rb
View
4 lib/cloud_crowd/server.rb
@@ -70,7 +70,7 @@ class Server < Sinatra::Base
# Distributes all work units to available nodes.
post '/jobs' do
job = Job.create_from_request(JSON.parse(params[:job]))
- WorkUnit.distribute_to_nodes
+ Thread.new { WorkUnit.distribute_to_nodes }
puts "Job ##{job.id} (#{job.action}) started." unless ENV['RACK_ENV'] == 'test'
json job
end
@@ -128,4 +128,4 @@ def initialize(*args)
end
-end
+end

0 comments on commit 93276ab

Please sign in to comment.
Something went wrong with that request. Please try again.