Hi, I'm Sam.

I like to create software, make music, and write about technology.

Find out more about me.

#deployment Posts

Easy Deployment with Heroku

Posted in deployment, development, heroku, rails, and video

I put together a quick screencast that shows the power of Heroku and how easy it is to deploy your app in literally seconds. I've started moving all of my little sites there. My company is even going to try a few of our new apps on there to see how we like it for bigger things.

Heroku is worth checking out even if you're happy with your current host. Their architecture is really impressive and the add-ons are really cool.

Gem Gotcha

At first my app gave me an error saying it couldn't load gems. I thought I needed to unpack my gems, but Heroku replied to me on Twitter and provided a really good alternative to unpacking!

Hosting Frustrations

Posted in deployment, development, engine-yard, heroku, and rackspace

Lately I've been struggling with good hosting. Here's three stories about some stuff I've tried. (Skip to the bottom of the post if you just want my conclusion and don't care about the stories.)

Heroku

I love Heroku. I did a screencast on how awesome they are a few months ago. Since then, I've moved all of my personal apps and all of Tasteful Works's apps to Heroku. They've been really great until recently.

I have two big complains (and one small one) with Heroku.

SSL

We were using SNI SSL for the Tasteful Works Store for awhile with great success. We realized that Google Chrome (as well as IE 6, which I don't really care about) don't support SNI SSL.

Chrome really yells at you when you go to a site using SNI SSL.

To get around this, you have to pay $100 a month ($95 more than SNI). This totally sucks. Heroku is awesome because they are affordable and easy. We finally decided to suck it up and pay the extra $95 a month. After paying they told it would take 1-2 business days to set it up. That totally sucks. After paying all of that money, we have to wait. I was pissed to say the least. They got it setup in 8 hours, but still.

The reason for the high price is due to how SSL works. Basically they spin up another $70/month Amazon EC2 instance to filter all of your requests through that into their routing grid. This is necessary because SSL requires that a certificate always uses the same IP. Understandable, but where the extra $30 comes from or why people can't share doesn't make sense to me.

HTTPS

Another recently frustrating thing with Heroku is how SSL environment variables work. rack.url_scheme is set to http or https depending on your request. Lots of Rack pieces rely on this. Heroku sets HTTP_X_FORWARDED_PROTO to https if it's an HTTPS request or omits that variable completely if it's an HTTP request.

This isn't a huge deal, but it caused me quite a few issues. I patched Refraction to work correctly on Heroku and all was happy.

Heroku told me on IRC that this is because requests sent internally are sent using HTTP and only HTTPS is used for the requests coming into the routing grid. That's fine and all, but it wish they informed applications of HTTPS in a more standard way.

Bundler

I know that they are working on better Bundler support, but it's kinda painful right now. You can't use gems from a git repository and whenever it re-bundles your app, it installs all of your gems, not just the ones needed for the current environment. So if you're like me and have a lot of testing gems, this takes forever.

Engine Yard Cloud

Some of the Engine Yard employees saw my frustrated Heroku tweets (which makes me laugh that they search for frustrated Heroku customers). They offered me two free weeks on the Engine Yard Cloud, which I thought was really cool.

After checking it out, I was very disappointed. I tried to get Markdownr setup on their service. After messing with it for over an hour, I gave up. Markdownr is probably one of the simplest Rails apps. (You can see the code on GitHub.) It only uses one gem besides Rails and doesn't use a database.

You have to add all of your gems that you need in their web portal. This seems so dumb. I wish it just used Bundler (especially since the guys that wrote it work at Engine Yard). I never got my app to launch. It kept saying the i18n gem wasn't found. I thought this might be due to using a pre-release version of Rails, so I installed them all separately and it still didn't work.

I emailed them and they said "Sorry that it looks like ey cloud is not for you." If it can't work with the simplest of apps, what can it work with? The price is also a bit high. (I also know a good friend that had a horrible experience with them.)

Rackspace Cloud

A few friends said they liked the Rackspace Cloud, so I thought I'd check it out since I am a little pissed at Heroku for all of the SSL junk and the Engine Yard Cloud just let me down. I checked out their site (which isn't to pretty) to get some more information, but didn't really feel like reading a poorly laid out marketing site. At the top of the page it said "Call Us," so I figured why not? I was curious if someone would answer at 11pm.

A support guy answered after just one ring. I was already impressed. If their support is that easy to contact, (granted it was at 11pm) that's really awesome. I told him I had some general questions about their platform and he was super nice and answered all of my questions.

I would totally go with Rackspace Cloud over any other VPS type service. They seem really awesome.

Final Thoughts

All of that said, Heroku is still hands down the easiest platform for hosting a Rails application. The Engine Yard Cloud is completely worthless. The Rackspace Cloud is really cool, but I don't want to manage a server.

So all of that said, we're staying on Heroku and paying the extra $95 a month for SSL.

New Server Script

Posted in deployment, development, gem, nginx, postgres, rackspace, ruby, and shell-script

I've found myself setting up lots of servers over at RackSpace Cloud lately. It seemed look a good idea to automate everything instead of leaving it up to myself to remember everything you have to do each time.

I wrote this little shell script to make life easier. It installs everything I need to run a Ruby on Rails app in a matter of minutes. It's designed to work with Cent OS 5.4+. Here's the script's main tasks:

  • Install Git 1.7.1.1
  • Install Ruby 1.8.7p299
  • Install RubyGems 1.3.7
  • Install Passenger 2.2.15
  • Install Nginx 0.8.45 (with Passenger and SSL modules)
  • Install Postgres 8.4.4
  • Initialize Postgres
  • Install ImageMagick 6.6.3-0
  • Install Bundler (latest)
  • Open port 80 in iptables
  • Open port 443 in iptables
  • Start Nginx
  • Start Postgres

For me, that's enough to get the bare bones of an app running. The rest, I let Bundler handle for me. I use this on all of my servers that I manage.

Let's get started already

All you have to do to setup your new server is run the following one line:

$ wget http://gist.github.com/raw/314865/new_server.sh;chmod +x new_server.sh;./new_server.sh

You'll have to press y twice at the beginning when yum asks you to install some stuff. After that, you can let it do its thing.

Configuration

It's super easy to add a new Nginx virtual host. All you have to do is add a file with the .conf extension to /usr/local/nginx/conf/virtual_hosts/. Here's a good example virtual host. Of course, you can configure any of the installed stuff like you normally would. My nginx.conf just makes setting up virtual hosts easy. After you edit any of the Nginx configuration files, you'll want to run service nginx reload to apply your changes.

One more thing

There's also another little script that I run after the main one that is more specific to my needs. This little guy creates /var/www/, setups the proper permissions, and installs some database related gems. You can run it with the following one line:

$ wget http://gist.github.com/raw/314865/z_after.sh;chmod +x z_after.sh;./z_after.sh

Updated 07/13/10: Bumped versions of packages and fixed ImageMagick