Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion definitions/features/foreman_tasks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "etc"

class Features::ForemanTasks < ForemanMaintain::Feature
MIN_AGE = 30
TIMEOUT_FOR_TASKS_STATUS = 300
Expand Down Expand Up @@ -177,7 +179,13 @@ def export_csv(sql, file_name, state)
f.write(csv_output)
f.close
end
execute("bzip2 #{filepath} -c -9 > #{filepath}.bz2")

# only if pbzip2, use max 8 threads, but at least 1 thread
cpu_count = Etc.nprocessors
threads = [[cpu_count / 2, 1].max, 8].min

compressor = system("which pbzip2 >/dev/null 2>&1") ? "pbzip2 -p#{threads}" : "bzip2"
execute("nice -n 10 #{compressor} #{filepath} -c -9 > #{filepath}.bz2")
FileUtils.rm_rf(filepath)
end

Expand Down