Throttle Down Rails Processes
TL;DR: You can use renice.
For each process named process{n}
, you can write something like
#!/bin/sh
renice +15 -p `ps ax | grep -E 'process1|process2|...|processn' | grep -v grep | awk '{print $1}' | tr '\n' ' '`
For your typical rails app, write a file named renice-rails
with the
following content:
#!/bin/sh
# filename: renice-rails
renice +15 -p `ps ax | grep -E 'ruby|node' | grep -v grep | awk '{print $1}' | tr '\n' ' '`
As for my case, listen or rb-fsevent gem is eating my CPU, which is still an open Rails issue, you could try:
#!/bin/sh
# filename: renice-rails
renice +15 -p `ps ax | grep 'rb-fsevent' | grep -v grep | awk '{print $1}' | tr '\n' ' '`
Add it somewhere in your $PATH
folders, chmod +x renice-rails
, run renice-rails
and you’re off to a good day of writing code!
Reference: OS X: throttle application CPU utilization