Push local git branch to server
I always forget how to do this
git push origin <new_branch_name>:refs/heads/<new_branch_name>
HAProxy to smooth things out
For a long time I've run a rails app behind nginx with 3 mongrels in a round robin configuration. It has worked for me pretty well. Recently I've added a few longish running reports and doubled my user count, and I've seen some sluggishness on my app. The issue is not that the 3 mongrels can't handle the load, the issue is that sometimes the requests get stacked up behind the long running process when there may be a couple of free mongrels just sitting there.
This is where HAProxy comes into the picture. HAProxy is an open source tcp/http load balancer. The magic that it gives us is the ability to only allow one connection at a time to our mongrels. So, if we have one long running process going, that mongrel will be skipped and the other 2 will be used until the first frees up. I've just started using this, but I think that it is making a difference already. You can watch a nice screencast from Mark Imbriaco of 37 signals on this approach.
My setup:
nginx ----> HAProxy ----> mongrels
MountainWest RubyConf
Was MountainWest RubyConf awesome? You be the judge:
Special Thanks to Mike Moore and Pat Eyler for putting on a great conference. The speakers were great and the atmosphere was top notch.
cap deploy:web:enable
I have finally decided to start putting up a warning page when doing maintenance on one of my sites. I decided that I wanted to use capistrano to get the job done. I checked the cap -T task list and noticed that there was already one there. It was pretty bleak looking so I decided to just roll my own page and put up a task to change the filename when needed and it would be picked up by nginx and displayed. I made up a page and put in on my production server under the system folder in the shared path and named it m.html. I then wrote up a couple of cap tasks to manage the renaming of the file and put them into my deploy.rb file:
desc "Turn on Maintenance Mode"
task :maint_on, :hosts => @web do
run "mv #{shared_path}/system/m.html #{shared_path}/system/maintenance.html"
end
desc "Turn off Maintenance Mode"
task :maint_off, :hosts => @web do
run "mv #{shared_path}/system/maintenance.html #{shared_path}/system/m.html"
end
disclaimer: there is probably already a way to do this using the original deploy:web:enable, but I didn't want to figure it out.
Family Directory
I decided to do a little experiment. I've written a little web application to be used as a family directory for the people on my mothers side of the family. So far, there has been a lot of support by the potential userbase, but I wonder if it will actually be used. The challenge might be to make is easy enough to use that it actually gets used.
The other question is will there be enough peer pressure to get everyone on it. I'm hoping for the best.
MyDaddyPuzzles and Extreme Makeover Home Edition update
Just posted a couple of pics from the final setup of the Extreme Makeover Home Edition puzzles. You can see them here towards the bottom of the page.
Gene Harris Project
The Adobe Group that I belong to is doing a little project for the Gene Harris Jazz Festival. We are making a little Flex Application for the display of Artists and some of their Media. I finally got the first bit of work done on this project. I created a datagrid for the display of the Artist, with their picture and Bio. And started on something to add and edit the artist info. This is part of the backend of the application, so it won't be seen by anyone. Hopefully I'm on the right track.
Scores on BroncoDashboard.com
I've added a new page to broncodashboard.com. I'm grabbing scores for the WAC games and other teams that I find interesting so that I can check them in one place. It is kind of a personal scoreboard, but I thought I'd put it out there for the general consumption.
MyDaddyPuzzles and Extreme Makeover Home Edition
MyDaddyPuzzles are being used in the upcoming Season Premier of Extreme Makeover Home Edition. You can read about it here.
rails, nginx, and SSL
This week I decided to buy an ssl certificate to start using with one of my websites. The site is running Rails 2.1.1, behind nginx as a reverse proxy. It was a learning experience to be sure and I'll try to document some of the steps that I had to take to get it working.
The first trick was getting the ca-bundle.crt file to be served by nginx. This is the intermediate ca file that allows browsers to recognize your certificate authority. The trick is to concatonate your certificate file and the ca-bundle.crt file and then place them on the webserver. I found that tidbit here. With Apache, you have a server directive for the ca-bundle file so this step is not necessary.
The next trick was to get nginx to let the rails app know what protocol was being used when requests came in using ssl. The magic is this line in the nginx.conf file
proxy_set_header X-FORWARDED_PROTO https;which I found here.
You also need to install the ssl_requirement plugin: ruby script/plugin install ssl_requirement. Which you can read about here.
Last, but not least, you need to tell nginx to turn on ssl and let it know where your certificates are, which is documented here.
That should about get you going with nginx, rails, and 3rd party ssl certificates.
ical is back
I found a free host for the iCal calendar of the broncodashboard.com iCal. So, it has been added back onto broncodashboard.com. I also added a scoreboard page that auto-updates with some WAC scores as well as some other teams that I like to follow. I used Hpricot, the Ruby library to gather the scores from espn.
rails printer icon helper
# in application_helper.rb
def printer_icon(top=50, left=550)
"<a href=\"#\" id=\"printer_icon\" style=\"position: absolute; top: #{top}px; left: #{left}px;\" onClick=\"window.print();return false;\">#{image_tag 'printer.png'} </a>"
end
#usage
<%= printer_icon %>
Works great.
Mini Server -- looks like bad hd
House For Sale
So, I had a meeting last evening and didn't get home until about 9pm. When I rolled up to the house, I couldn't help but notice that there was a for sale by owner sign in my front yard. That was a surprise.
The market is pretty bad right now, so I don't really expect that much will come of this, but it is kind of exciting. Potentially homeless.
Rails 2.1
Biggest issue for me with the upgrading to Rails 2.1 from 2.0.2 seems to be the eager loading. Where I have used :include => :some_association in my find code and haven't put the full tablename.column syntax in my :conditions SQL, the table doesn't get loaded and errors occur, so I've been busy adding included table names to my conditions strings.
Rails 2.1 also seems to have different behavior when it comes to how dates are handled. If a partial date is input, I end up with some weird dates instead of seeing the multi-param error that I used to see. Not sure I'm liking that very much.