Don't Forget to Plant It!

Running FiveRuns TuneUp in a Separate Environment

FiveRuns’ TuneUp is a great tool for profiling your Rails app, but by default it is always running in development. This causes two issues 1) every request is slower in development as it is always collecting profiling data, and 2) the TuneUp bar can mess with the layout of your application, especially if you’re rendering content in iframes like we do with Skribit. So instead of having TuneUp always run in development mode, I’ve changed it to run only when the server is started in a new environment called ‘profiler’. Here’s how I did it.

First, you need to tell TuneUp to only run in the profiler environment. You do this by modifying config/tuneup.rb (create this file if it doesn’t already exist):

1
2
3
4
Fiveruns::Tuneup.config do |config|
config.environments.delete('development')
config.environments << 'profiler'
end

Next, copy the development configuration block in config/database.yml and create a new block called profiler:

1
2
3
4
5
6
7
profiler:
adapter: mysql
encoding: utf8
database: YOUR_DATABASE
username: YOUR_USERNAME
password: YOUR_PASSWORD
socket: /tmp/mysql.sock

Finally, create your profiler environment configs by copying your development configs:

1
cp config/environments/development.rb config/environments/profiler.rb

You’re all set! Now, to run the server with TuneUp on, just run the server in the profiler environment:

1
script/server -e profiler

Now, I have TuneUp available to me only when I’m looking to optimize performance.

Comments