diff --git a/lib/tasks/s3.rake b/lib/tasks/s3.rake index 7f5a7a4cad2..39ec32b3364 100644 --- a/lib/tasks/s3.rake +++ b/lib/tasks/s3.rake @@ -194,7 +194,15 @@ task "s3:ensure_cors_rules" => :environment do end task "s3:upload_assets" => [:environment, "s3:ensure_cors_rules"] do - assets.each { |asset| upload(*asset) } + pool = + Concurrent::FixedThreadPool.new( + ENV["DISCOURSE_S3_UPLOAD_ASSETS_RAKE_THREAD_POOL_SIZE"] || Concurrent.processor_count, + ) + + assets.each { |asset| pool.post { upload(*asset) } } + + pool.shutdown + pool.wait_for_termination end task "s3:expire_missing_assets" => :environment do