Skip to content

Instantly share code, notes, and snippets.

@hotakasaito
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hotakasaito/342b55858eaa3720166c to your computer and use it in GitHub Desktop.
Save hotakasaito/342b55858eaa3720166c to your computer and use it in GitHub Desktop.
paperclipから呼び出すコマンドの負荷を少しでも下げたい ref: http://qiita.com/hotakasaito/items/8751c5fb05e7883af3f2
require 'paperclip/helpers'
Paperclip::Helpers.module_eval do
def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
command_path = options[:command_path]
Cocaine::CommandLine.path = [Cocaine::CommandLine.path, command_path].flatten.compact.uniq
if logging? && (options[:log_command] || local_options[:log_command])
local_options = local_options.merge(:logger => logger)
end
Cocaine::CommandLine.new("#{Rails.env.production? ? 'ionice -c3 -n7 ' : ''}nice -n19 #{cmd}", arguments, local_options).run(interpolation_values)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment