Main

Load Averages, Explained

Aug 03 by Andre

Just did a writeup on Understanding CPU Load Averages over on the Scout Blog ... it uses a traffic analogy to illustrate what load averages numbers depending upon how many cores/processors you have.

If you like the post, feel free to upvote on hacker news!

Continue reading "Load Averages, Explained

Rails script/runner + logging + cron + production

May 26 by Andre

A quick tip: you're using script/runner in production (likely invoked via cron for a periodic background task), you probably are not seeing logging output in your production.log. Why? In production mode, the Rails logger doesn't auto-flush. As far as I can tell, the logging output is simply lost.

An easy solution that worked for me: adding a Rails.logger.flush to my script/runner call in cron.

Before:

*/1 * * * * deploy PATH_TO_APP/script/runner -e production 'MyClass.do_it'

After:

*/1 * * * * deploy PATH_TO_APP/script/runner -e production 'MyClass.do_it; Rails.logger.flush'

Bonus tip: to capture any other output from the cron task, use this:

*/1 * * * * deploy PATH_TO_APP/script/runner -e production 'MyClass.do_it; Rails.logger.flush' >> PATH_TO_APP/log/my.log 2>&1

Happy logging!

Continue reading "Rails script/runner + logging + cron + production