Make Rails (and other dev servers) use less CPU

Is Rails eating your CPU in development? Try lowering its priority using renice(1), a standard BSD utility that should be available in OS X and most Linux distributions. Here's a shell script that will automatically reset the priority to +15 to common development processes:

#!/usr/bin/env sh
sudo renice +15 -p $(ps ax | grep -E 'ruby|node|watchman|postgres' | grep -v grep | awk '{print $1}' | tr '\n' ' ')

Save this as renice-dev into one of your bin paths, and give it a chmod +x renice-dev. You can type renice-dev after you start your development processes to "renice" them.

The lowest priority is +19 (only run when nothing else is running), the default is 0, and the highest is -20 (makes things go very fast).