FIX: Limit concurrent `assets:precompile` to number of available cores.
This commit is contained in:
parent
23b4ab9bf9
commit
13dde44c72
|
@ -151,9 +151,11 @@ def compress(from, to)
|
||||||
end
|
end
|
||||||
|
|
||||||
def concurrent?
|
def concurrent?
|
||||||
|
executor = Concurrent::FixedThreadPool.new(Concurrent.processor_count)
|
||||||
|
|
||||||
if ENV["SPROCKETS_CONCURRENT"] == "1"
|
if ENV["SPROCKETS_CONCURRENT"] == "1"
|
||||||
concurrent_compressors = []
|
concurrent_compressors = []
|
||||||
yield(Proc.new { |&block| concurrent_compressors << Concurrent::Future.execute { block.call } })
|
yield(Proc.new { |&block| concurrent_compressors << Concurrent::Future.execute(executor: executor) { block.call } })
|
||||||
concurrent_compressors.each(&:wait!)
|
concurrent_compressors.each(&:wait!)
|
||||||
else
|
else
|
||||||
yield(Proc.new { |&block| block.call })
|
yield(Proc.new { |&block| block.call })
|
||||||
|
|
Loading…
Reference in New Issue