lib/runit-man/service_info.rb in runit-man-1.9.8 vs lib/runit-man/service_info.rb in runit-man-1.10.0

- old
+ new

@@ -1,9 +1,11 @@ require 'runit-man/log_location_cache' require 'runit-man/service_status' class ServiceInfo + SPECIAL_LOG_FILES = %w(lock config).freeze + attr_reader :name def initialize(a_name) @name = a_name @files = {} @@ -95,9 +97,33 @@ def log_file_location rel_path = ServiceInfo.log_location_cache[log_pid] return nil if rel_path.nil? File.expand_path(rel_path, log_run_folder) + end + + def log_file_path(file_name) + dir_name = File.dirname(log_file_location) + File.expand_path(file_name, dir_name) + end + + def log_files + r = [] + dir_name = File.dirname(log_file_location) + Dir.foreach(dir_name) do |name| + next if ServiceInfo.itself_or_parent?(name) + next if SPECIAL_LOG_FILES.include?(name) + full_name = File.expand_path(name, dir_name) + r << { + :name => name, + :size => File.size(full_name), + :modified => File.mtime(full_name) + } + end + if r.length >= 2 + r.sort! { |a, b| a[:modified] <=> b[:modified] } + end + r end def send_signal(signal) return unless supervise? File.open(File.join(supervise_folder, 'control'), 'w') do |f|