Ruby On Rails - Use endless loop when server starts

389 views Asked by At

I'm using feedzirra to retrieve rss feeds from a website. To start I'm using a loop that check if the rss feed has been updated or not. I have been successful in doing this through the terminal. But if I want to automaticly turn on this function when I start the server. How do I accomplish that?

FeedEntry.update_feed_loop("URL")

Thats the function I'm calling that is represented in feed_entry.rb

1

There are 1 answers

1
cpuguy83 On BEST ANSWER

You could use the Clockwork gem to run at certain intervals... or Clockwork + DelayedJob... or rake + cron... several combinations out there for this.

You should think of the loop as a background task that needs to be run and quit at certain intervals, not continuously hitting the RSS server and on all the time. If you were to create an "endless loop" this would tie up your rails process so it couldn't do anything else other than that one task.