خرید بک لینک

Vote count: 0

I am trying to run a job at every 20 seconds. I am using whenever gem but as per its documentation it allows minimum 1 minute of time.

scheduler

every 1.minute do
  ruer "DailyNotificationChecker.send_notifications"
end

job

i thought i can use sleep method and make it sleep for 20 seconds but then it will go to infinite mode and what will happen if my cron will it this method again.

class DailyNotificationChecker 
    def self.send_notifications
        Rails.logger.info "Triggered NotificationChecker"
        if RUN_SCHEDULER == "true"
          Rails.logger.info "Ruing Performer"
          notes = Note.unprocessed
          if notes.present?
            notes.each do |note|
              RealtimeNotificationChecker.performer(note.user_id,"note_created")
              note_hash = {}
              note_hash[:note_id] = note.id
              url = URI.parse(PROCESS_NOTE_API_URL)
              resp, data = Net::HTTP.post_form(url, note_hash)
            end
          end
        sleep 20  #=> workaround for to sleep 20 seconds
        end
      end
end

asked 8 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 1 تير 1395 ساعت: 15:48

صفحه بندی