I got the invitation to CloudFoundry (http://cloudfoundry.com), the new PaaS (Platform as a Service) sponsored by VMWare, so I decided to deploy my side project PushPuppy to evaluate the platform. CloudFoundry (CF) supports a wider selection of platforms and technologies including Ruby (1.8.7 and 1.9.2), NodeJS, and Java 6, as opposed to Heroku’s Ruby-only support. So for weekend or experimental projects, CF is an excellent choice.
The basic application deployment process was pretty straightforward, download the vmc gem, run a few commands to push the app to CF and fingers-crossed hoping that the app starts successfully. For PushPuppy, I’m using Rails 3 and MongoDB with Mongoid as the ORM, and I had to change a few things to get the app deployed properly.
Because CloudFoundry provide a ready environment for your app, the configuration is only available at deploy time. Since Mongoid tries to connect to the database when your app is starting, the app would fail in a normal CloudFoundry push with something like
Error: Application ‘pushpuppy’s state is undetermined, not enough information available.
and if you hit the public URL, the site will return
VCAP ROUTER: 404 - DESTINATION NOT FOUND
Essentially the app couldn’t get started in the backend, so you’ll get a 404 since CF can’t route the request to the application server. Luckily, CloudFoundry provides some basic logging access to help you troubleshoot the issue:
$ vmc logs YOUR_APP_NAME
The command will show you all the logs from stderr or stdout. Using the error logs I was able to get Mongoid to connect properly.
First of all, add
gem ‘json’
to your Gemfile. CloudFoundry requires all the gems to be explicitly listed in the Gemfile.
Next, Remove the mongoid.yml file, and create a new initializer: config/initializers/mongoid.rb
The idea is to sniff if there’s a VCAP_SERVICES environment variable, we’d connect to MongoDB using the CloudFoundry provided parameters. Now update your app again and hopefully your app will start.
This is the full log for my deployment of PushPuppy with Ruby1.9.2
Conclusion:
Pros:
- CloudFoundry is a cool new PaaS that is free and supports a great variety of bleeding-edge technologies like Mongo, Redis, NodeJS. I’m especially intrigued about the NodeJS support since I’ve been looking for a service to host my projects.
Cons:
- The deployment process is simple, but still not as streamlined as Heroku’s. The error messages are not as clear as they should be, especially for a new starter, it may takes a little bit of digging to figure out what goes wrong.
- CF currently doesn’t support domain mapping. So it remains only a development/test platform. Hopefully VMWare will add this feature soon.
- No rake support, so basic things like db:seed or running custom rake tasks directly are not possible. CF automatically runs db:migrate, but for db:seed you have to put in an initializer (more here).
- No console support.
- No way to have direct access to your data so please don’t run your production app here
Nonetheless, CloudFoundry is a cool platform and it makes me as a developer happy because I now can experiment with new technologies without having to worry about the hosting and sysadmin part.
