Get Started with Nodejitsu
Today we have Melbourne-based front end developer Mark Dalgleish talking about Nodejitsu, a simple Node.js platform.
Watch to find out more.
In this JumpCast, we’re going to look at deploying our note apps into the cloud, using the nodejitsu service. Now, one of the great things about Nodejitsu, is they have a free service to get you started, and it’s really painless to get up and running. The first thing to do is to go over to the terminal, and we’re going to use Node package manager, or NPM to install locally the jitsu package.
Now what this is going to do, is going to the NPM registry, download the latest version of the nodejitsu command mine utility. With this, you’ll be able to sign up for nodejitsu account, then login to it and use it to interact with this servers, provisioning new websites, and uploading your node projects, so now that’s complete.
Let’s clear the screen, and we can create an account by saying ‘jitsu Signup. It’s going to prompt you for some details to get your account sorted out, but I’m going to assume that you’ve gone through that process okay, and the next step, once you’ve got an account as you can say, is “jitsu login”. It’s going to ask you for your account details. Let’s just log in now.
Once this has logged you in, every command you use, using the jitsu tool, is against your nodejitsu account. What we can do, first of all, is we want to have an application that we can actually upload to nodejitsu, so to do that, we’re first going to install
Express, the Node application framework. Using Express, we’re just going to quickly scaffold up really basic app, something that can run on the nodejitsu servers. Now that we’ve got that, we can say “express jumpcast”; we’ll create a new application called jumpcast. If we cd into jumpcast, and open it in our editor.
You’ll see we’ve got package js in file, with information about our new application. Let’s rename it to “JumpCast”, and we’ll be a bit more specific about those start scripts. Running NPM style will run node app.js. Running app.js will start out our express server, and hitting the default route is going to render the index views. If we look at the index.jade, you can see we’ve got our basic homepage here.
If we change this from “title” or say, “jumpcast”, and we’ll say “nodejitsu with”. So we’ve modified our basic app, and from here, if we run NPM START, you’ll see our application fails to start. This is because we first need to install our dependencies, which are currently listed in the package js file.
If we run NPM install, we’re going to download the dependences for our new application, which is Express and Jade. Once these are downloaded, we’ll be able to start our app using the NPM start script. First of all, it’s going to get the dependencies for Jade and Express, might take a few seconds, and that’s complete. We can run “NPM start”. This is the command that’s going to run on the server once we upload to nodejitsu, but for now, it’s running locally. If we go over to the chrome, go to local lost 3000, you can see our barebones application is up and running, so it’s ready to go.
From here, we can close our application down. We can now deploy our app to nodejitsu. We run “jitsu deploy”. It’s going to ask us for some more details about our application, so we want to put it at jumpcast.jitsu. Ask us which version of node it can run on, 0.8 is fine. The default details it’s asked us all look good, so we’ll go with that.
What it’s doing is it’s communicating with nodejitsu provisioning up new application for us, and it’s uploading a new application. In a few moments, what’s going to happen is on this server, it’s going to download the dependencies for our application. Then it’s going to start running on jumpcast.jit.su, so you can see right now, it’s starting our new application remotely. Then, in a few moments, we’ll be able to go and see this running live on the nodejitsu servers, where not only we can access it, but anyone else.
Now, application’s up and running. If we go over to chrome, and we go to jumpcast.jit.su, you’ll see our application is now up and running.
What you’ve seen is it basic example of how to get a node application created and uploaded to nodejitsu using an account that we’ve created from the command line, logged in, and then deployed it to this service. If you’d like to see more, definitely go to nodejitsu.com and have a look at their free service, and there’s also paid service if you’d like to get more serious with the cloud hosting on their system. Thanks for watching.