class ProcfileUpstartExporter::Destroyer
Attributes
procfile_parser[RW]
Public Class Methods
new(procfile_parser = ProcfileUpstartExporter::ProcfileParser.new)
click to toggle source
# File lib/procfile_upstart_exporter/destroyer.rb, line 2 def initialize procfile_parser = ProcfileUpstartExporter::ProcfileParser.new self.procfile_parser = procfile_parser end
Public Instance Methods
destroy(application, path, procfile = nil)
click to toggle source
# File lib/procfile_upstart_exporter/destroyer.rb, line 6 def destroy application, path, procfile = nil ProcfileUpstartExporter.logger.debug 'Starting Upstart jobs deletion ' \ "for `#{ application }'" if procfile destroy_jobs application, path, procfile_parser.parse(procfile) .map(&:name) else destroy_all_jobs application, path end ProcfileUpstartExporter.logger.debug 'Deleted Upstart jobs for ' \ "`#{ application }'" end
Private Instance Methods
destroy_all_jobs(application, path)
click to toggle source
# File lib/procfile_upstart_exporter/destroyer.rb, line 23 def destroy_all_jobs application, path stopping_output = IO.popen(['stop', application], err: [:child, :out]).read ProcfileUpstartExporter.logger.debug stopping_output FileUtils.rm_rf File.join(path, "#{ application }.conf") FileUtils.rm_rf File.join(path, application) end
destroy_jobs(application, path, processes_names)
click to toggle source
# File lib/procfile_upstart_exporter/destroyer.rb, line 30 def destroy_jobs application, path, processes_names Dir.glob("#{ path }/#{ application }/*.conf").each do |job_absolute_path| process_name = File.basename job_absolute_path, '.conf' unless processes_names.include? process_name job = File.join application, process_name stopping_output = IO.popen(['stop', job], err: [:child, :out]).read ProcfileUpstartExporter.logger.debug stopping_output FileUtils.rm_rf File.join(path, "#{ job }.conf") end end end