require 'tasks_scheduler/checker/log' module TasksScheduler class Checker include Singleton CHECK_INTERVAL = 15 LOG_ON_FILE_ENV_KEY = 'TASKS_SCHEDULER_LOG_ON_FILE'.freeze LOGS_KEYS = %w(rails stdout stderr).freeze def run check_log running = true Signal.trap('TERM') { running = false } while running Rails.logger.info('Checking all tasks...') ::ScheduledTask.all.each(&:check) Rails.logger.info("All tasks checked. Sleeping for #{CHECK_INTERVAL} second(s)...") sleep(CHECK_INTERVAL) end end def log_path rais_log.path end def logs LOGS_KEYS.map { |key| send("#{key}_log") } end LOGS_KEYS.each do |log_key| class_eval <