PERF: run ImageMagick conversions with nice 10

This lowers the priority of all image resizes so they do not clog CPU on
machines running low on resources
This commit is contained in:
Sam
2019-01-09 09:21:58 +11:00
parent e08a3f719c
commit 7e4a43afc6

View File

@@ -330,7 +330,7 @@ class OptimizedImage < ActiveRecord::Base
MAX_PNGQUANT_SIZE = 500_000
def self.convert_with(instructions, to, opts = {})
Discourse::Utils.execute_command(*instructions)
Discourse::Utils.execute_command("nice", "-n", "10", *instructions)
allow_pngquant = to.downcase.ends_with?(".png") && File.size(to) < MAX_PNGQUANT_SIZE
FileHelper.optimize_image!(to, allow_pngquant: allow_pngquant)