mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -330,7 +330,7 @@ class OptimizedImage < ActiveRecord::Base
|
|||||||
MAX_PNGQUANT_SIZE = 500_000
|
MAX_PNGQUANT_SIZE = 500_000
|
||||||
|
|
||||||
def self.convert_with(instructions, to, opts = {})
|
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
|
allow_pngquant = to.downcase.ends_with?(".png") && File.size(to) < MAX_PNGQUANT_SIZE
|
||||||
FileHelper.optimize_image!(to, allow_pngquant: allow_pngquant)
|
FileHelper.optimize_image!(to, allow_pngquant: allow_pngquant)
|
||||||
|
|||||||
Reference in New Issue
Block a user