Tag Archive for 'cron'

Tickling ruby apps every 5 minutes

I posted a while ago about the problems on DreamHost killing my ruby applications’ start-up. Currently I have a solution, yet it is experimental and certainly not reliable. To tickle the application every 5 minutes, the application processes won’t be idle and won’t be turned off by DreamHost. Since my application don’t get much traffic, I need this desperate measure to keep the application from dying. In return, I can access the applications in an instant as if they were  PHP applications.

My web application is small and lightweight since it uses Sinatra which is a very light framework, so I know it won’t be needing much resources. The starting up is the only problem, since running ruby applications on DreamHost creates a sudden spike on the ram by starting up.

To tickle the application, you need to create a cron job that will visit the application every 5 minutes.

*/5 * * * * /usr/bin/curl http://your-domain.com/ -s -o /dev/null

I noticed some odd behavior though. When you try to run another ruby application on the same server, the loading of my ‘tickled’ applications are also being delayed.

I had this idea a long while ago, and when I saw that this method being used by other ruby users hosted on DreamHost, I decided to try it out too.