I Am Not Myself


Node.js It’s Not Just for Websites

So I have been working on a node.js project recently, that I was hosting on Heroku. Sadly, Heroku doesn’t allow socket.io based node apps to use true websockets. So I asked my good friend Adron who was the best Heroku-like node host out there that did support it. He suggested Nodejitsu.

So I signed up and my hopes were immediately dashed when I discovered they are metering access to their beta. You have to camp out on their activation site waiting for them to allot a few more activations. This sounded boring. So I decided to automate it with node of course. I fired up Sublime Text 2 and ripped this out.

var util = require('util'),
    exec = require('child_process').exec,
    rest = require('restler');

var alertMe = function(){
	exec('say -v Cellos Bobby, come get your nodejitsu beta');

var checkSite = function(){
	util.puts('checking if I can get you into the beta yet.');
	rest.get('http://activate.nodejitsu.com/').on('complete', function(result){
		if(result instanceof Error) {
			util.puts('Error: ' + result.message);
		} else {
			if(result.indexOf('We\'ve hit our limit today. Please try again later.') < 0)
				util.puts('damn it...');

var pollingSite = setInterval(checkSite, 10000);

Yes this script hits the website every 10 seconds checking to see if the limit message is not on the page and play a message if it is not. I was sufficiently amused by this that I gisted it and posted to twitter. Funny thing is with in a minute I had been retweeted by Joshua Holbrook the support lead for Nodejitsu and got the following response from NodeKohai the IRC bot for the Nodejistu channel.

@NotMyself Very nice! Now come join ‪#nodejitsu‬ on freenode to claim your prize!

You see sometimes being a smart ass is a bonus. It gets you free things! Also here is a quick video showing the script in action.

2 responses to “Node.js It’s Not Just for Websites

  1. Justin Bozonier June 18, 2012 at 7:44 pm

    Maybe I’m missing context but I’ve launched Node.js Socket.IO apps on Heroku. Here’s a link to what I’m thinking: https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku

    • Bobby Johnson June 18, 2012 at 8:00 pm

      Yeah if you read that page it says they don’t support websockets but suggest doing long polling instead. Which is what I was referring to..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: