lib/newrelic-management/controller.rb
def daemon # rubocop: disable AbcSize, MethodLength
      # => Windows Workaround (https://github.com/bdwyertech/newrelic-management/issues/1)
      ENV['TZ'] = 'UTC' if OS.windows? && !ENV['TZ']

      scheduler = Rufus::Scheduler.new
      Notifier.msg('Daemonizing Process')

      # => Alerts Management
      alerts_interval = Config.alert_management_interval
      scheduler.every alerts_interval, overlap: false do
        Manager.manage_alerts
      end

      # => Cleanup Stale Servers
      if Config.cleanup
        cleanup_interval = Config.cleanup_interval
        cleanup_age = Config.cleanup_age

        scheduler.every cleanup_interval, overlap: false do
          Manager.remove_nonreporting_servers(cleanup_age)
        end
      end

      # => Join the Current Thread to the Scheduler Thread
      scheduler.join
    end
def daemon # rubocop: disable AbcSize, MethodLength
      # => Windows Workaround (https://github.com/bdwyertech/newrelic-management/issues/1)
      ENV['TZ'] = 'UTC' if OS.windows? && !ENV['TZ']

      scheduler = Rufus::Scheduler.new
      Notifier.msg('Daemonizing Process')

      # => Alerts Management
      alerts_interval = Config.alert_management_interval
      scheduler.every alerts_interval, overlap: false do
        Manager.manage_alerts
      end

      # => Cleanup Stale Servers
      if Config.cleanup
        cleanup_interval = Config.cleanup_interval
        cleanup_age = Config.cleanup_age

        scheduler.every cleanup_interval, overlap: false do
          Manager.remove_nonreporting_servers(cleanup_age)
        end
      end

      # => Join the Current Thread to the Scheduler Thread
      scheduler.join
    end
=> Daemonization for Periodic Management