Invoke with memory limits
This commit is contained in:
@@ -47,16 +47,23 @@ module Pipeline
|
||||
analysis_run.prepare_iteration do |iteration_folder|
|
||||
File.write("#{iteration_folder}/two_fer.rb", 'puts "hello"')
|
||||
end
|
||||
begin
|
||||
analysis_run.analyze!
|
||||
rescue => e
|
||||
puts e
|
||||
ensure
|
||||
puts "---"
|
||||
puts analysis_run.stdout
|
||||
puts "==="
|
||||
puts analysis_run.stderr
|
||||
puts "---"
|
||||
puts analysis_run.success?
|
||||
puts analysis_run.exit_status
|
||||
puts analysis_run.result
|
||||
puts "---"
|
||||
puts analysis_run.stdout
|
||||
puts analysis_run.stderr
|
||||
puts "DONE"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "pipeline/analyzer_repo"
|
||||
require "pipeline/validation/check_invokable"
|
||||
|
||||
@@ -3,24 +3,25 @@ require 'open3'
|
||||
|
||||
module Pipeline::Util
|
||||
class RuncWrapper
|
||||
attr_accessor :binary_path, :suppress_output
|
||||
attr_accessor :binary_path, :suppress_output, :memory_limit
|
||||
|
||||
def initialize
|
||||
@binary_path = File.expand_path "./opt/runc"
|
||||
@suppress_output = false
|
||||
@memory_limit = 3000000
|
||||
end
|
||||
|
||||
def run(container_folder)
|
||||
container_id = "analyzer-#{Time.now.to_i}"
|
||||
|
||||
run_cmd = ExternalCommand.new("#{binary_path} --root root-state run #{container_id}")
|
||||
run_cmd = ExternalCommand.new("bash -x -c 'ulimit -v #{memory_limit}; #{binary_path} --root root-state run #{container_id}'")
|
||||
run_cmd.timeout = 5
|
||||
|
||||
kill_cmd = ExternalCommand.new("#{binary_path} --root root-state kill #{container_id} KILL")
|
||||
|
||||
Dir.chdir(container_folder) do
|
||||
begin
|
||||
run_cmd.call!
|
||||
run_cmd.call
|
||||
ensure
|
||||
kill_cmd.call
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user