Want new rubies on your webbies?



by Jay Fajardo

The other night, my usually painless  Webbynode deployment routine was shaken up when I deployed two projects that used the latest version of  Mongoid.

It turns out that  Mongoid dependencies starting from 3.x require you to use Ruby 1.9.3  while Webbynode only has 1.9.2 when creating a standard RAPP instance.

Webbynode RAPP Deployment

The solution isn’t as hard as it seems. Most of the stress I experienced was tracing the problem and finding out that there wasn’t anything on the web to directly point you to a solution.

So instead of searching for “Ruby 1.9.3 on Webbynode”, I tried researching for “RVM on Webbynode” and found  this article by Andre Honsberg, which pointed me in the right direction.

To make things simpler for the common Webbynode deployer, here are are the steps one needs to take to make Ruby 1.9.3 (and future rubies) work on your webby.

 

RVM is the key.

The Ruby Version Manager (RVM) is clearly the best way to manage multiple rubies in development and can make your deployments more flexible when you deal with many ruby projects using varying ruby versions.

Note My web server preference is Nginx + Passenger and the following steps are for that stack.

First, get on your webby’s shell using the CLI and install RVM.

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

This will download and run the RVM installation and create the .rvm folder and sources within your home directory (/var/rapp).

 

Next, add a reference in your .bashrc to the RVM working directory

echo '[[ -s "/var/rapp/.rvm/scripts/rvm" ]] && source "/var/rapp/.rvm/scripts/rvm"' >> ~/.bashrc

 

Now re-initialize your bash terminal session

~/.bashrc

 

To test if the everything is all fine, type the following command and check if you get rvm is a function.

type rvm | head -1

 

Installing Ruby with RVM.

All good? Awesome. Now we can install our ruby.

rvm install 1.9.3

This installs 1.9.3 in your .rvm directory. You may want to download other rubies which will all be found in .rvm for you to manage and use as you want.

 

Now let’s make 1.9.3 our default ruby.

rvm use --default 1.9.3

 

Let’s check our default ruby now by running it with the -v directive.

ruby -v

 

Slow clap.

Note Anytime you want to see a list of rubies installed, you can issue the rvm list command where you’ll also see the current and default ruby version. Incidentally, anytime you want to revert to the system ruby version you can issue the rvm use system command.

 

Making Nginx use your new ruby version.

So now that we’ve got Ruby 1.9.3 on the web by, we’ll want to make Nginx use it for our app.

Let’s start by editing nginx.conf.

sudo vi /opt/nginx/conf/nginx.conf

 

Look for the passenger_ruby directive which will likely be defined to point to the system ruby wrapper.

passenger_ruby /var/rapp/user/bin/ruby;

replace this line with

passenger_ruby /var/rapp/.rvm/bin/ruby-1.9.3-p327;

This will direct Nginx to start using your new ruby when Nginx next starts.

Note I used patch 327 of Ruby which was the latest one at the time I tried this.

 

Just to make sure my wrappers are properly formed, I issue the below command to update RVM and ask it to re-generate the wrappers.

rvm get head && rvm reload && rvm repair all

 

Restart Nginx and resume fighting the good fight.

 

Verifying the version

To confirm that we’re using the new ruby version, from the webbynode CLI:

wn remote ruby -v

 

Thanks to Andre Honsberg/ @andrehonsberg for the great article on installing RVM on Ubuntu.

 

 

FireflyAPI, An SMS API for developers by developers



by Adrian Co

FireflyAPI is a system that allows users to send SMS messages via POST request through its API, allowing developers to notify their users via SMS. Firefly API is able to send SMS to all networks here in the Philippines. It is proudly crafted by our awesome developers Jason Torres and Victor Solis, together with our friends at Kickstart Philippines.

In the future, we will be supporting sender masking so we can include your company’s name to appear to your consumer. Incoming messages will also be available soon so you can engage with your customers.

Firefly API is complete with documentation which is included in the website upon sign-up. If you have any concerns, comments or feedback, please feel free to contact Jason Torres. Currently, Firefly API is at beta and an invite-only service. Hurry up so you can be a part of our beta users by requesting an invite via the Firefly API website.

Installing the latest MongoDB package on Webbynode



by Jay Fajardo

Webbynode makes it easy to install MongoDB on your webby via the webbynode command line utility.

The only drawback is that the version installed by the native recipe is 1.6.5. This posed a problem when we started using Alex Reisner’s Geocoder gem with MongoDB’s geospatial methods, particularly $nearSphere.

To make a long story short, the 1.6.5 and earlier versions are broken as far as geospatial is concerned and the only fix is to update mongodb on your webby.

 

Remove mongodb from your addons

The first thing that needs to be done is to remove the mongodb addon from your webby. No need to worry since all your DBs will remain intact.

From your local terminal:

wn addons remove mongodb

This is required so the deploy script doesn’t re-install the old version of MongoDB the next time you do a wn push.

Edit your project, commit your changes, and perform a normal webbynode deploy using the CLI.

wn push

Webbynode should then proceed to remove the currently installed MongoDB package.

 

Configure the Ubuntu Package Management System (APT)

Go into your webby’s shell using the webbynode CLI

wn ssh

APT requires all packages to be signed with GPG keys. On the command line, import the 10gen public GPG Key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Edit /etc/apt/sources.list and add the following to add the 10gen repository:

deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

Now issue the following command to update the package manager with the 10gen  repository:

sudo apt-get update

 

Install Packages

Issue the following command which will install the latest stable version of MongoDB:

sudo apt-get install mongodb-10gen

Allow it to replace any previous MongoDB versions installed. That’s it!

The latest stable version of MongoDB should now be installed on your webby as a service.

 

Installation procedure was derived from http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-linux/