Wednesday, 30 January 2013

A Meteor nodejs app to heroku in 5 minutes

Meteor is an amazing framework to rapidly build fully interactive web applications based on node.js and MongoDB.

I had a look at the video on the home page and I was quite impressed. I wanted to check it out myself on the web so I installed the framework

curl https://install.meteor.com | /bin/sh

and then went ahead with creating a new app.

If you create a new app you probably won't have a feeling of where to start. So instead of starting from scratch, try starting from one of the examples

meteor create --example parties

Now that you have the code just browse through the client and the server folders, you can get a feeling of how to structure a web app.

Ok now, let's chuck it on heroku

cd parties
heroku create devparties --stack cedar --buildpack https://github.com/jordansissel/heroku-buildpack-meteor.git

The command above will create a new heroku app called devparties using this buildpack that has all the configuration to use a MongoHQ free db.

Now let's use git to add to heroku

git init
git commit -a -m "Initial commit"

Before pushing you will have to add the remote (heroku) git url

git remote add heroku git@heroku.com:devparties.git
git push heroku master

OK, that's it. You have your app running.

There is one last thing you command you'll have to run to set the ROOT_URL ( not sure, must be in the buildpack somewhere.. ) Anyway, if you get an error like

Starting process with command `PATH=.meteor/local/usr/bin:.meteor/local/usr/lib/meteor/bin:bin:/usr/local/bin:/usr/bin:/bin NODE_PATH=.meteor/local/usr/lib/meteor/lib/node_modules MONGO_URL=mongodb://heroku:1e2cc27d5f5415f5cd31783b6fa29afa@linus.mongohq.com:10011/app11455582 node .meteor/local/build/main.js`
2013-01-31T00:03:57+00:00 app[web.1]:             ^
2013-01-31T00:03:57+00:00 app[web.1]: app/packages/meteor/url_common.js:14
2013-01-31T00:03:57+00:00 app[web.1]: 
2013-01-31T00:03:57+00:00 app[web.1]:     at Object.Meteor.absoluteUrl (app/packages/meteor/url_common.js:14:13)
2013-01-31T00:03:57+00:00 app[web.1]:     at app/packages/accounts-password/email_templates.js:3:20
2013-01-31T00:03:57+00:00 app[web.1]:       throw new Error("Must pass options.rootUrl or set ROOT_URL in the server
2013-01-31T00:03:57+00:00 app[web.1]: Error: Must pass options.rootUrl or set ROOT_URL in the server environment
2013-01-31T00:03:57+00:00 app[web.1]:     at Array.forEach (native)
2013-01-31T00:03:57+00:00 app[web.1]:     at Function._.each._.forEach (/app/.meteor/local/build/server/node_modules/underscore/underscore.js:79:11)
2013-01-31T00:03:57+00:00 app[web.1]:     at run (/app/.meteor/local/build/server/server.js:99:7)
2013-01-31T00:03:57+00:00 app[web.1]:     at /app/.meteor/local/build/server/server.js:113:21
2013-01-31T00:03:58+00:00 heroku[web.1]: Process exited with status 1

then run the command

heroku config:add ROOT_URL=http://devparties.herokuapp.com

Monday, 28 January 2013

MongoDB online course videos and how to download them

hey guys, The MongoDB guys are doing some free online course on MongoDB. The MongoDB for DBAs is already online with the first two weeks
if you want to download the videos and watch them online (like me on the tube) you can check you this project on github.
To get it running on Ubuntu make sure you have python 2.7 and a few other dependencies.

Run

Run the following commands and you'll be downloading in secs.

git clone git://github.com/nonsleepr/edu_10gen_dl.git
vi config.py // change email and password in the config file. 
// Also set domain to 'education.10gen.com'
sudo apt-get install python-bs4
sudo apt-get install python-mechanize
python edu_10gen.py


The config.py needs to have your 10gen username (email) and password.

Hope it helps!