Steve P. Sharpe Ruby/Rails/Android Cornwall - United Kingdom

December 9, 2013 0

Loading local environment variables with RSpec

If like me, you deploy your Rails apps to Heroku, then one of the many benefits are environment variables, which are one of the requirements of developing a twelve-factor app. These are great for keeping your config out of source control.

You can also use local environment variables using the dotenv gem. These are stored at the root of your Rails app in a .env file, make sure you don’t commit this to source control and you’re all good. If you use the  foreman gem, one of it’s dependencies is the dotenv gem so there is no need to add another line to your Gemfile.

When you add Rspec in to the mix though, it doesn’t automatically load these local environment variables by default.

This is easily resolved by editing spec/spec_helper.rb and adding the following to the top of the file.

September 28, 2013 0

Installing New Relic when using PHP-FPM

New Relic

This blog is hosted on an Ubuntu 12.10 droplet over at Digital Ocean (affiliate link) and uses a LEMP stack, using nginx, instead of Apache,  along with PHP-FPM.

We use New Relic extensively where I work and I also wanted to use it on my blog, and why not. Normally installation is super easy, however when trying to install New Relic on the brand new droplet it was complaining that it couldn’t find PHP.  I had already installed PHP via apt-get install php5-fpm, however this alone doesn’t make PHP available via the command line. In order to install New Relic successfully I had to run apt-get install php5-cli as well. After this, the install continued without a hitch and within a few minutes New Relic was capturing data. Great!

Another step you might like to complete is to monitor your server with New Relic as well, which again, is very easy to set up.
Instructions for setting up server monitoring can be found in the docs