1

My application need continous fetching of data from Twitter. I used twitter gem to access Twitter API. Have used #rufus-scheduler to hit the Twitter API after every half an hour, but it is not working, as some time it is blocked by the Twitter API for increasing limit.

joe
  • 11
  • 1

1 Answers1

1

I have already answered to a similar question here Background task

Basically, if you want to periodically fetch something on the Twitter API, you can use a cron job, but if you want to do it in real time, consider using a background job.

Example

while true
  if thereIsSomethingToDo
     # Do something here...
  else
     sleep 60 # Could be + or -
  end 
end

There is different ways to manage background jobs. Here is one:

  1. Wrap your code in a rake task
  2. Run this rake task from a process monitor like Monit or God
Community
  • 1
  • 1
basgys
  • 4,320
  • 28
  • 39