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