module ForemanDebian::EngineHelper
Public Instance Methods
cleanup()
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 14 def cleanup threads = [] each_file do |path| next if @exported.include? path threads << Thread.new { remove_file path } end ThreadsWait.all_waits(*threads) end
each_file(&block)
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 40 def each_file(&block) get_files.each do |path| block.call(path) end end
exec_command(command)
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 46 def exec_command(command) Open3.popen3(command) do |i, o, e, w| i.close out, err, wait = o.read, e.read, w status = wait ? wait.value : $? raise "Command `#{command}` failed: #{err}" unless status.success? out end end
export_file(path)
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 23 def export_file(path) @exported.push(path) @output.info " create #{path.to_s} " end
get_files()
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 33 def get_files paths = Pathname.glob(@export_path.join("#{@app}-*")) paths.select do |path| path.read.match(/# Autogenerated by foreman/) end end
pidfile(name)
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 9 def pidfile(name) name = "#{@app}-#{name}" Pathname.new('/var/run').join(name).join(name + '.pid') end
remove_file(path)
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 28 def remove_file(path) File.unlink path @output.info " remove #{path.to_s}" end
setup()
click to toggle source
# File lib/foreman_debian/engine_helper.rb, line 4 def setup @exported = [] @output = ForemanDebian::logger end