Tuesday, 6 October 2009

rotating nginx logs

Since moving most of my systems over to plain Ubuntu on EC2 (as opposed to using ec2OnRails) I've needed to figure out certain things - like rotating the nginx logs (using Nginx instead of apache).

Simply create a file in /etc/logrotate.d/nginx that looks like this

/opt/nginx/logs/*.log {
daily
missingok
rotate 30
compress
delaycompress
sharedscripts
postrotate
/etc/init.d/nginx restart
endscript
}

Friday, 24 July 2009

move from ec2onrails

Recently the performance on FilmAmora.com has been plummeting. And I had no idea why. Often apache was timing out waiting for a mongrel. Very little development has happened recently on FilmAmora, so I was stumped.
So - like a good developer - I took this as a chance to make a drastic move from ec2onrails machines to straight ubuntu, with everything else installed by hand.

It has made a HUGE difference. So much so that I could actually drop a machine from the configuration and still have better response times.

I followed these instructions to get started: rails-nginx-passenger-ubuntu. I also switched to nginx and ruby enterprise edition - just to make following the instructions easier.

So far so good. It took a couple hours and presto a leaner meaner installation. My NewRelic Apdex score went from .5 to .9.

Friday, 17 July 2009

expiring action_cache

I was having a bugger of a time expiring my cache. The problem was the cache_path.
I have index actions that take filters. So, I created a cache_path for my action caching:

caches_action :index, :layout => false, :cache_path => Proc.new { |c| "#{c.params[:league_id]}/index/#{c.params.values.sort.to_s}" }


Which means that all my caches end up in a nice tree of 'views/[league name]'. But, how to expire a whole part of the cache tree when there could be dozens of nodes as people could be searching on last names too.

What I found was that expire_action was NOT the way to go. expire_fragment lets you pass in a regular expression. Now in my sweeper I have this:

  def expire_cache_for(player)
expire_fragment(%r{views/#{player.league.to_param}.*})
end


Which will expire all the cached code for the player's league.

Tuesday, 23 June 2009

installing rmagick on osx leopard

I've put up a gist of a bash file that works (as of today) to do this from source.
You can clone it:

git clone git://gist.github.com/134823.git gist-134823

Sunday, 7 June 2009

Ruby Toolbox

Just found this site (via a tweet)... seems to have a comprehensive list of rails extensions, broken down by category.
If only they linked to them!

Ruby Toolbox

Saturday, 6 June 2009

Google's Page Speed

Google releases Page Speed - get it here - an open-source Firefox plugin similar to Yahoo's YSlow