Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
1185 lines (856 sloc) 50.8 KB
<title>Nodejitsu Handbook</title>
body {
font: 14px/1.4 Arial, sans-serif;
padding: 50px 180px;
h1 {
padding-left: 5px;
border-bottom: 3px solid #eee;
pre {
margin: 15px 0;
padding: 15px;
border: 1px solid #eee;
a {
color: #000000;
a:hover {
color: blue;
<body><div class='mp'>
<h1><p><a href=""><img style="position: absolute; top: 0; right: 0; border: 0;" alt="Fork me on GitHub" src="" /></a></p>
The Nodejitsu Handbook</h1>
<p><em>A gentle introduction to the art of Nodejitsu</em></p>
<h2 id="Quick-Links-">Quick Links:</h2>
<li><a href="book.pdf">The Nodejitsu Handbook (.pdf)</a></li>
<li><a href="">Frequently Asked Questions</a></li>
<li><a href="">The Nodejitsu Cheatsheet</a></li>
<li><a href="">The NPM Cheatsheet</a></li>
<li><a href="">The package.json Reference</a></li>
<li><a href="">How To Set Up Custom DNS</a></li>
<li><a href="">API Documentation</a></li>
<li><a href="">How To Build The Handbook</a></li>
<div class='mp'>
<h1>Table of Contents</h1>
<li><a data-bare-link="true" href="#introduction">Introduction</a></li>
<li><a data-bare-link="true" href="#hiworld">Hello World: A Tutorial</a></li>
<li><a data-bare-link="true" href="#features">Platform Features</a></li>
<li><a data-bare-link="true" href="#jitsu">Jitsu</a></li>
<li><a data-bare-link="true" href="#webapp">Nodejitsu Web Application</a></li>
<li><a data-bare-link="true" href="#api">JSON API</a></li>
<li><a data-bare-link="true" href="#haibu">Create Your Own Cloud With Haibu</a></li>
<li><a data-bare-link="true" href="#opensource">Open Source Projects</a></li>
<li><a data-bare-link="true" href="#faq">Frequently Asked Questions</a></li>
<li><a data-bare-link="true" href="#support">Support</a></li>
<li><a data-bare-link="true" href="#apx">Appendices</a></li>
<div class='mp'>
<p><a name="introduction"></a></p>
<p>Welcome to the Nodejitsu handbook. This document will help familiarize you with
deploying your Node.js applications to the cloud while also providing
detailed information about Nodejitsu's platform-specific features and about
where to get help when you need it.</p>
<p>This is a living document which you can submit patches to at
<a data-bare-link="true" href=""></a>.
Note that this file is generated from the individual content files in the
<code>/chapters</code> folder, so any edits should be made to those source files, not <code></code>.</p>
<h2 id="Who-Is-Nodejitsu-">Who Is Nodejitsu?</h2>
<p>We are a collection of seasoned developers who have been devoted to the Node.js
community since 2009. We are community leaders who have created and contributed to
hundreds of open-source Node.js projects. If you have used Node.js, you've
probably used some of the projects we've helped create.</p>
<p>You can find our open source projects at <a data-bare-link="true" href=""></a>, <a data-bare-link="true" href=""></a>,
<a data-bare-link="true" href=""></a>, and <a data-bare-link="true" href=""></a>.</p>
<h2 id="What-Is-Nodejitsu-">What Is Nodejitsu?</h2>
<p><a href="">Nodejitsu</a> is a Platform as a Service and a Marketplace
for Node.js applications. Nodejitsu allows you to seamlessly deploy your Node.js
applications into the cloud with a myriad of additional features. Our platform
provides a robust suite of functionality to assist in the development,
management, and deployment of Node.js applications. Our deployment tools are the
most user-friendly in the industry and our customer support is unparalleled.</p>
<h2 id="Getting-Started">Getting Started</h2>
<p>So you wish to learn the ways of Nodejitsu? Excellent! You only need to know
three things to get started:</p>
<li><p>We're <a href="">Nodejitsu</a>, and we can give you scalable,
fault-tolerant cloud hosting for your Node.js apps - and we're the best you'll
<li><p>Getting started with <a data-bare-link="true" href="#hiworld">your first app</a> is simple with our
<a data-bare-link="true" href="#jitsu">jitsu</a> command-line interface - we'll <a data-bare-link="true" href="#hiworld">show you how</a>.</p></li>
<li><p>Most of our stack is <a href="">open source</a> and you can
<a data-bare-link="true" href="#opensource">use our tools</a> anywhere else you'd like to.</p></li>
<p>The Nodejitsu Handbook also contains information on <a data-bare-link="true" href="#deployment">other ways to deploy your
applications</a> and where to <a data-bare-link="true" href="#support">find support</a>.</p>
<div class='mp'>
<h1>Hello World: A Tutorial</h1>
<p><a name="hiworld"></a></p>
<p>In this tutorial, you will write a simple "hello world" web application in
Node.js, and then deploy it using jitsu, Nodejitsu's command line interface.</p>
<p>Before you get started, you should have
<a href="">node.js</a> installed. If you are using
a node.js version older than v0.6.0 (not recommended) you will also need to
separately install
<a href="">Node Package Manager</a> (npm).</p>
<h2 id="Write-A-Server">Write A Server</h2>
<p>Let's start with a very basic Node.js http server. Create a folder called
<code>myapp/</code> and then create a file inside the folder called <code>server.js</code>. Inside
this file, write the following code:</p>
<pre><code>// requires node's http module
var http = require('http');
// creates a new httpServer instance
http.createServer(function (req, res) {
// this is the callback, or request handler for the httpServer
// respond to the browser, write some headers so the
// browser knows what type of content we are sending
res.writeHead(200, {'Content-Type': 'text/html'});
// write some content to the browser that your user will see
res.write('&lt;h1&gt;hello, i know nodejitsu.&lt;/h1&gt;');
// close the response
}).listen(8080); // the server will listen on port 8080
<p>That's all the code you'll need for starters. Save your server and get ready to
<h2 id="Deploy-with-Jitsu">Deploy with Jitsu</h2>
<p>In this tutorial, we will use <a href="">jitsu</a> to deploy
our "hello world" application. Jitsu is a
<a href="">Command Line Interface</a>
for using Nodejitsu's platform. We've designed jitsu to be
suitable for command line beginners, but still be powerful and extensible
enough for production usage. If you aren't a fan of the command line or don't
have terminal access you can still do app deployments through the
<a href="">Nodejitsu Web Application</a>.</p>
<p>If this is your first time deploying an application and you are eager to get
started, we recommend using jitsu: it has a one line installer, it's
self-documenting, and with it you'll be able to deploy your app in seconds.
Plus, it's what's in the tutorial.</p>
<h2 id="Installation">Installation</h2>
<p>In order to install jitsu, open a terminal and type:</p>
<pre><code> [sudo] npm install jitsu -g
<p>This command will install jitsu on your system; the <code>-g</code> makes npm install it
globally, rather than as a local module.</p>
<p><img alt="" src="" /></p>
<p>After installation, run the <code>jitsu</code> command from your command line. Since it's
your first time using jitsu, you will be prompted to log in with an existing
account or to create a new account.</p>
<p><img alt="" src="" /></p>
<p><strong>Once you've logged in, you can deploy your app immediately.</strong></p>
<h2 id="One-Line-Deployment">One Line Deployment</h2>
<p>Open a terminal:</p>
<pre><code>cd /home/me/myapp
jitsu deploy
<p>This will create a new application snapshot, generate and/or update project
metadata, and deploy the project in the current path to
<a href="">Nodejitsu</a>. If it's your first deployment, you'll be
prompted for some information such as <em><u>your app's name</u></em>, its
<em><u>nodejitsu subdomain</u></em>, and its <em><u>start script</u></em>. It's really easy and we promise it will
only take a few seconds.</p>
<pre><code>prompt: subdomain (myapp): myapp
prompt: scripts.start (server.js):
prompt: version (0.0.0):
<p>Now just open up your favorite browser, and go to
<code></code>. If everything has been set up correctly, then
you, too, are on the path of nodejitsu!</p>
<div class='mp'>
<h1>Features of the Nodejitsu Platform</h1>
<p><a name="features"></a></p>
<p>The Nodejitsu platform makes writing and deploying web applications a snap!
In addition to simple yet powerful tools for deployment, the Nodejitsu platform
also has snapshot management, database hosting and connectivity, and more!</p>
<p>There are three main tools for deploying and managing applications to Nodejitsu:</p>
<li><a data-bare-link="true" href="#jitsu">Jitsu</a>, The Nodejitsu command line tool</li>
<li>The Nodejitsu <a data-bare-link="true" href="#web_admin">Web Application</a>, An easy to use web interface for
managing your applications</li>
<li>Nodejitsu's JSON <a data-bare-link="true" href="#json_api">API</a></li>
<p>Each of these tools allow developers to access the same functionality.</p>
<h2 id="Application-Scalability-with-Drones">Application Scalability with Drones</h2>
<p>Each deployed application runs as a <a href="">drone</a> on a <a href="">haibu</a> application server. Because of this architecture, one app can be served by <em>any amount of drones on arbitrary machines</em>, giving you many options for scaling your application.</p>
<h2 id="Zero-Downtime-Deploys">Zero Downtime Deploys</h2>
<p>When deploying a new application, nodejitsu keeps hosting your old app version until the new deploy is confirmed to be running. This means your applications never go down, even if you have a bad deploy.</p>
<h2 id="Multi-Version-Node-Support">Multi-Version Node Support</h2>
<p>Nodejitsu allows users to choose which version of node they want their
application to run on. In order to set your node version, specify it in your
<code>package.json</code>'s "engines" field. For example:</p>
"author": "Nodejitsu &lt;;",
"version": "0.1.0",
"scripts": {
"start": "node bin/server"
"analyze": false,
"name": "helloworld",
"engines": {
"node": "v0.6.x"
<p>If no node engine is specified, jitsu will prompt for it automatically.</p>
<h2 id="Snapshots">Snapshots</h2>
<p><a name="features/snapshots"></a></p>
<p>Every time you deploy to Nodejitsu, we automatically take a
<a href="">snapshot</a> of your
application. Using any of our tools, you can view and manage snapshots, or even
roll back to an old snapshot when disaster strikes in your production
environment. <em>During a deploy, nodejitsu will create a new snapshot automatically.</em></p>
<p>Jitsu commands for snapshot management include:</p>
<li><code>jitsu snapshots list &lt;app-name></code> will list all snapshots for an application.</li>
<li><code>jitsu snapshots activate &lt;app-name></code> allows you to choose which snapshot your drones are running.</li>
<li><code>jitsu snapshots fetch &lt;app-name></code> will download a specified snapshot of your application to your computer.</li>
<h2 id="Databases">Databases</h2>
<p><a name="features/databases"></a></p>
<p>Applications on Nodejitsu are ready to be connected to any database. If you
already have a database running, Nodejitsu can connect to your pre-existing
database. If you require a new database, Nodejitsu can provide you <em>free</em>
instances of several different types of databases. These free instances are
great for development purposes or hobby sites. If you require a high traffic
or production database we provide an easy upgrade path to industrial strength
database hosting.</p>
<h3 id="Creating-new-Databases">Creating new Databases</h3>
<p>If you require database hosting you can create a new database instance of any
of our supported databases using <a data-bare-link="true" href="#jitsu">jitsu</a> or Nodejitsu's <a data-bare-link="true" href="#api">API</a>.
Cloud database hosting is currently provided by
<a href="">IrisCouch</a>, <a href="">RedisToGo</a>
and <a href="">MongoHQ</a>.</p>
<h3 id="Existing-Databases">Existing Databases</h3>
<p>If you already have an externally hosted Database, Nodejitsu is capable of
connecting to it. We've got Database hosting if you need it, but we fully
support externally hosted Databases.</p>
<h3 id="Connecting-Applications-to-Databases">Connecting Applications to Databases</h3>
<p>Whenever you create a database using Nodejitsu, you will be provided with all
the information you need to connect to your database.</p>
<h4 id="CouchDB">CouchDB</h4>
<p>If you run <code>jitsu databases create couchdb myCouch</code>, jitsu will tell you the
url for your new couchdb from iriscouch:</p>
<pre><code>info: Welcome to Nodejitsu user
info: It worked if it ends with Nodejitsu ok
info: Executing command databases create couchdb myCouch
info: Database myCouch was created.
data: Database Type: couch
data: Database Name: myCouch
data: Connection url:
data: SSL connection url:
info: Nodejitsu ok
<p>You can connect to this database using any http client, or a couchdb specific
library. For example, you can connect with curl:</p>
<pre><code>$ curl
<p>Or, you can connect with <a href="">nano</a>:</p>
<pre><code>var nano = require('nano')('');
<p>You can also access your database in your browser by going to .</p>
<h4 id="MongoDB">MongoDB</h4>
<p>If you run <code>jitsu databases create mongo myMongo</code>, jitsu
will supply a connection string for your new mongo database on mongohq:</p>
<pre><code>info: Welcome to Nodejitsu user
info: It worked if it ends with Nodejitsu ok
info: Executing command databases create mongo myMongo
info: Database myMongo was created.
info: Database name: myMongo
info: Database type: mongo
info: Connection url: mongodb://
info: Nodejitsu ok
<p>You can connect to this using the <code>mongo</code> CLI client tool like so:</p>
<pre><code>$ mongo -u nodejitsu -p pass
<p>or with the <code>mongodb-native</code> module:</p>
<pre><code>var mongodb = require('mongodb');
var db = new mongodb.Db('somedatabase',
new mongodb.Server('', 10027, {})
); (err, db_p) {
if (err) { throw err; }
db.authenticate('nodejitsu', 'pass', function (err, replies) {
// You are now connected and authenticated.
<p>or with mongoose:</p>
<pre><code>var mongoose = require('mongoose');
<p>You can copy-paste this url directly into your mongo library's connect method.
For example, in <a href="">Mongoose</a>:</p>
<pre><code>var mongoose = require('mongoose');
<h4 id="Redis">Redis</h4>
<p>Running <code>jitsu databases create redis myRedis</code> will create a redis instance supplied by redistogo:</p>
<pre><code>info: Welcome to Nodejitsu user
info: It worked if it ends with Nodejitsu ok
info: Executing command databases create r testRedis
info: A new redis has been created
data: Database Type: redis
data: Database Name: testRedis
data: Connection host:
data: Connection port: 5309
data: Connection auth: pass
info: Nodejitsu ok
<p><strong>Note:</strong> Some versions of jitsu may show a connection string, eg. <code>redis://</code>.</p>
<p>You can connect to your redis with the <code>redis-cli</code> cli client:</p>
<pre><code>$ redis-cli -h -p 5309 -a pass
<p>or with the <code>redis</code> module:</p>
<pre><code>var redis = require('redis');
var client = redis.createClient(5309, '');
client.auth('pass', function (err) {
if (err) { throw err; }
// You are now authed with your redis.
<h2 id="Environment-Variable-Management">Environment Variable Management</h2>
<p>Nodejitsu allows users to modify the environment variables exposed to their
apps using jitsu and our other tools. When an environment variable is changed
it is necessary restart your app for it to take effect.</p>
<p>Available commands are <code>list</code>, <code>get</code>, <code>set</code>, <code>delete</code>, and
<p><code>jitsu env list</code> will list any and all environment variables in an apps
current working directory (Note: the app needs to have been deployed before the
environment variables can be accessed).<br />
<code>jitsu env list &lt;myapp></code> will list any and all environment variables related
to <code>&lt;myapp></code> in an account.<br />
<code>jitsu env get &lt;key></code> will display the apps key environment variable
<code>&lt;value></code>.<br />
<code>jitsu env set &lt;key> &lt;value></code> will set the apps <code>&lt;key></code> environment variable
to <code>&lt;value></code>.<br />
<code>jitsu env delete &lt;key></code> will delete the apps <code>&lt;key></code> environment variable.<br />
<code>jitsu env clear</code> will delete all of the apps environment variables after a
<p>An Example:</p>
<pre><code>$ jitsu env set NODE_ENV production
<p>This will set the environment variable $NODE_ENV to have the string value
"production". Remember, this will not take effect until the app is restarted
(<code>jitsu apps restart</code>).</p>
<h2 id="SSL-on-nodejitsu-com-subdomains">SSL on subdomains</h2>
<p>Our balancers can proxy https to http, so you get SSL on subdomains automatically! For example, the app behind <a data-bare-link="true" href=""></a> is serving http, but visiting <a data-bare-link="true" href=""></a> works without any special action on our part.</p>
<p>Please note that this only works with <code></code> (not <code></code> or <code></code>) at this time.</p>
<p>If you need to identify if you are receiving http or https traffic use the
<code>x-forwarded-proto</code> response header value, see
<a href=""></a> for more information on headers
passed through the balancers.</p>
<h2 id="Custom-Domains">Custom Domains</h2>
<p>We allow users to host their applications on custom domains by specifying their
app's domains in their <code>package.json</code> and then properly configuring their DNS.
If you'd like to know how, just read the instructions at <a data-bare-link="true" href=""></a>!</p>
<h3 id="SSL-Certificates-for-Custom-Domains">SSL Certificates for Custom Domains</h3>
<p>Our balancers use <a href="">SNI</a> which allow them to receive SSL traffic from multiple domains---including yours! If, for example, you owned <code></code> and wanted secure connections, all you need are your .pem and .key files!</p>
<p><em>Note: This feature is not exposed through our API or other tools at this time. If you need this feature, please contact support at <code></code>.</em></p>
<h2 id="Addons">Addons</h2>
<p><em>Note: Coming soon!</em></p>
<p>Addons add functionality to your apps by extending and adding features to
Nodejitsu's platform and integrating third party services. For instance,
one of our addons provides powerful <a href="">Mailchimp</a>-based
mailing list management.</p>
<h2 id="Marketplace">Marketplace</h2>
<p><em>Note: Coming soon!</em></p>
<p>The Marketplace is an online store where you can browse ready to deploy
Node.js Applications. The Marketplace is a great place to start if you are new
to Node.js development or want to share your existing Node.js Application with
the world.</p>
<div class='mp'>
<h1>The Jitsu Client</h1>
<p><a name="jitsu"></a></p>
<p><a href="">Jitsu</a> is a
<a href="">Command Line Interface</a>
(CLI) for interacting with the Nodejitsu platform. It's open-source and easy
to use.</p>
<h2 id="Installation">Installation</h2>
<p>Jitsu is distributed using the Node Package Manager (npm). Installing jitsu
with npm is as simple as a single command:</p>
<pre><code> [sudo] npm install -g jitsu
<p>This command installs jitsu to your Node path, so that it may be run like any other global shell command.</p>
<h2 id="Usage">Usage</h2>
<p>Commands for jitsu follow this pattern:</p>
<pre><code>jitsu &lt;resource> &lt;action> &lt;param1> &lt;param2> ...
<p>For example, in <code>jitsu apps deploy</code>, "apps" is the resource and "deploy" is the
<h3 id="jitsu-deploy-jitsu-apps-deploy-">jitsu deploy (jitsu apps deploy)</h3>
<p><code>jitsu deploy</code> will attempt to deploy the application in the current directory
to <a href="">Nodejitsu</a>. It deploys your application using the
following steps:</p>
<li>Creates the application (if necessary)</li>
<li>Creates or validates the package.json</li>
<li>Packages and creates a new snapshot</li>
<li>Stops the application (if necessary)</li>
<li>Starts the application</li>
<h3 id="jitsu-list-jitsu-apps-list-">jitsu list (jitsu apps list)</h3>
<p><code>jitsu list</code> lists your applications, as well as their respective states,
subdomains, entry points and latest snapshots.</p>
<h3 id="jitsu-help-resource-action">jitsu help <var>resource</var> <var>action</var></h3>
<p><em>Jitsu is self-documenting.</em>
All commands will yield friendly messages to you if you specify incorrect
parameters. Additionally, <code>jitsu help</code> will return useful help messages about
any given resource or resource/action pair. for instance:</p>
<pre><code>josh@pidgey:~$ jitsu help apps deploy
info: Welcome to Nodejitsu
info: It worked if it ends with Nodejitsu ok
info: Executing command help apps deploy
help: Deploys an application using the following steps:
help: 1. Creates the application (if necessary)
help: 2. Creates or validates the package.json
help: 3. Packages and creates a new snapshot
help: 4. Stops the application (if neccessary)
help: 5. Starts the application
help: jitsu deploy
help: jitsu apps deploy
info: Nodejitsu ok
<p>If no resource and/or action are specified, then <code>jitsu help</code> alone will
describe what resources are available.</p>
<h3 id="jitsu-apps-action">jitsu apps <var>action</var></h3>
<p>In addition to the commands aliased to <code>jitsu create</code>, <code>jitsu deploy</code> and
<code>jitsu list</code>, the <code>apps</code> resource allows you to create, destroy, stop, start and
otherwise interact with your applications.</p>
<h3 id="jitsu-env-action">jitsu env <var>action</var></h3>
<p>Jitsu allows you to set environment variables on your production environment.
For example, <a href="">Express</a>, a popular node.js web framework,
uses the <code>NODE_ENV</code> environment variable to change behavior based on whether the
environment is for development or production. In the case of Express, nodejitsu
has <code>NODE_ENV</code> set to "production" by default, but if one wanted to change this
variable or add more for their application, <code>jitsu env</code> supplies the tools to
do so.</p>
<h3 id="jitsu-config-action">jitsu config <var>action</var></h3>
<p><code>jitsu config</code> commands allow you to edit your local jitsu configuration file.</p>
<h3 id="jitsu-snapshots-action">jitsu snapshots <var>action</var></h3>
<p><code>jitsu snapshots *</code> commands allow you to work with snapshots for your
Applications on Nodejitsu. Snapshots are images of your Application's code that
are deployed to the Nodejitsu Platform.</p>
<p>For commands that take a <code>&lt;name></code> parameter, if no parameter is supplied,
jitsu will attempt to read the package.json from the current directory.</p>
<h3 id="jitsu-users-action">jitsu users <var>action</var></h3>
<p><code>jitsu users *</code> commands allow you to work with new or existing Nodejitsu user
accounts. You will be prompted for additional user information as required.</p>
<h3 id="jitsu-install">jitsu install</h3>
<p><code>jitsu install</code> is a built-in tool for downloading "starter apps" to speed up development. For example, here's how to use <code>jitsu install</code> to download a "hello world" application:</p>
<pre><code>josh@onix:/tmp$ jitsu install helloworld
info: Welcome to Nodejitsu jesusabdullah
info: It worked if it ends with Nodejitsu ok
info: Executing command install helloworld
info: Installing helloworld locally.
warn: Downloading packages from npm, this may take a moment...
info: helloworld installed.
help: You can now jitsu deploy this application
prompt: Would you like to start this application locally? (yes): no
info: Nodejitsu ok
josh@onix:/tmp$ cd helloworld
josh@onix:/tmp/helloworld$ ls
bin node_modules package.json
<h2 id="Configuring-jitsu">Configuring jitsu</h2>
<p>All user-level configuration data for your local jitsu install is located in the <em>.jitsuconf</em> file located in your home directory. Directly modifying this file is not advised. You should be able to make all configuration changes using <code>jitsu config</code>.</p>
<h3 id="Selected-Properties-of-jitsuconf">Selected Properties of .jitsuconf</h3>
<li><em>loglength</em>: Change this to modify the default length of returned logs from <code>jitsu logs</code>.</li>
<li><em>loglevel</em>: Change this to modify the logging levels displayed by jitsu. Defaults to "info".</li>
<li><em>colors</em>: Change this to false to turn off jitsu's colors. Defaults to <code>true</code>.</li>
<li><em>analyze</em>: Change this to false to disable require-analyzer for all apps. Defaults to <code>true</code>.</li>
<div class='mp'>
<h1>Nodejitsu Web Application</h1>
<p><a name="webapp"></a></p>
<p>The Nodejitsu Web Application allows developers to administrate their
applications through a web interface. This interface allows access to the same deployment functionality that can be found in <a data-bare-link="true" href="#jitsu">jitsu</a> or the <a data-bare-link="true" href="#api">JSON API</a>.</p>
<p>The web admin interface may be found at <a data-bare-link="true" href=""></a>.</p>
<div class='mp'>
<h1>JSON API</h1>
<p><a name="api"></a></p>
<p>Nodejitsu provides a web API for developers who want to interact with the
Nodejitsu platform programatically. This API is built to be
<a href="">RESTful</a> and
communicates via <a href="">JSON</a>. The API is the most
low-level way of interacting with the Nodejitsu platform. For most deployment
scenarios you should use our command line tool, <a href="#jitsu" data-bare-link="true">jitsu</a>, or the
<a href="#webapp" data-bare-link="true">online administrative interface</a>.</p>
<h2 id="API-Clients">API Clients</h2>
<p>Nodejitsu has a JSON API client for node.js, which may be found <a href="">here</a> (along with API clients in other languages as they are developed). Jitsu is implemented by using the node.js API client.</p>
<h2 id="Authentication">Authentication</h2>
<p>Most of the calls to the API will require that you authenticate using your Nodejitsu account. If you do not have an account it is possible to create one using the API, the <a href="#jitsu" data-bare-link="true">jitsu CLI</a>, or just by visiting <a href="" data-bare-link="true"></a>. Currently, we support <a href="">Basic Authentication</a>. If you haven't used Basic Auth before, don't fret; it's easy!</p>
<p>Here is an example using the command line utility,
<a href="">Curl</a>:</p>
<pre><code> // get all applications for User "Marak"
curl --user Marak:password
<h2 id="Applications">Applications</h2>
<p>Applications are the core of the Nodejitsu API. Each application represents a set of Node.js code plus a package.json which contains meta-data about the application such as it's dependencies, database connections, configuration settings and authors. For more information about the package.json format see: <a href="#package_json" data-bare-link="true">package.json</a></p>
<h3 id="Get-all-Applications-for-a-User">Get all Applications for a User</h3>
<pre><code> GET /apps/:user-id
<h3 id="Create-a-new-Application">Create a new Application</h3>
<pre><code> POST /apps/:user-id
{ package.json }
<h3 id="Start-an-Application">Start an Application</h3>
<pre><code> POST /apps/:user-id/:app-id/start
<h3 id="Stop-an-Application">Stop an Application</h3>
<pre><code> POST /apps/:user-id/:app-id/stop
<h3 id="Restart-an-Application">Restart an Application</h3>
<pre><code> POST /apps/:user-id/:app-id/restart
<h3 id="Update-an-Application">Update an Application</h3>
<pre><code> PUT /apps/:user-id
{ package.json }
<h3 id="Delete-an-Application">Delete an Application</h3>
<pre><code> DELETE /apps/:user-id/:app-id/remove
<h2 id="Snapshots">Snapshots</h2>
<h3 id="Make-an-existing-snapshot-the-active-app">Make an existing snapshot the active app</h3>
<pre><code>POST /apps/:user-id/:app-id/snapshots/:id/activate
<h3 id="Activate-Deploy-a-snapshot">Activate / Deploy a snapshot</h3>
<pre><code>POST /apps/:user-id/:snapshots/:id
<h3 id="Show-a-catalog-of-all-Snapshot-for-an-Application">Show a catalog of all Snapshot for an Application</h3>
<pre><code>GET /apps/:user-id/:app-id/snapshots
<h3 id="Show-the-contents-of-a-Snapshot">Show the contents of a Snapshot</h3>
<pre><code>GET /apps/:user-id/:app-id/snapshots/:id
<h2 id="Users">Users</h2>
<h3 id="Create-a-new-User-Sign-up-for-a-free-Nodejitsu-account">Create a new User / Sign-up for a free Nodejitsu account</h3>
<p>Email address is the only required field.</p>
<pre><code> POST /users/:user-id
email: ""
<h3 id="Confirm-a-User-account">Confirm a User account</h3>
<p>All User accounts must be confirmed. When a new User is created, a confirmation email will be sent to the email address associated with that user. In this email there will be an invite code. This code must be sent to the API to confirm the account.</p>
<pre><code>POST /users/:user-id
inviteCode: "SecretCode"
<h3 id="Update-User">Update User</h3>
<pre><code>PUT /users/:user-id
password: "new_password"
<h2 id="Databases">Databases</h2>
<h3 id="Create-a-new-Database">Create a new Database</h3>
<pre><code> POST /databases/:user-id/:database-id
type: "couch" || "redis" || "mongo"
<h3 id="Get-information-about-a-Database">Get information about a Database</h3>
<pre><code>GET /databases/:user-id/:database-id
<h3 id="Delete-a-Database">Delete a Database</h3>
<pre><code>DELETE /databases/:user-id/:database-id
<h2 id="Logging">Logging</h2>
<p>Logging is a very important feature in any professional grade Node.js
application. Nodejitsu provides integrated logging solutions for your
applications. Your logs are always saved and ready to be retrieved.</p>
<h3 id="Get-all-logs-for-a-user">Get all logs for a user</h3>
<pre><code>POST /logs/:user-id/
"from": "NOW-3YEARS",
"until": "NOW",
"rows": 15
<h3 id="Get-logs-for-a-specific-application">Get logs for a specific application</h3>
<pre><code>POST /logs/:user-id/:app-id
"from": "NOW-3YEARS",
"until": "NOW",
"rows": 15
<h2 id="Marketplace">Marketplace</h2>
<h4 id="Get-all-Marketplace-Applications">Get all Marketplace Applications</h4>
<pre><code>GET /marketplace
<h4 id="Get-a-specific-Marketplace-Application">Get a specific Marketplace Application</h4>
<pre><code>GET /databases/:user-id/:id
<div class='mp'>
<h1>Create Your Own Cloud With Haibu</h1>
<p><a name="haibu"></a></p>
<p>Haibu is an open-source tool for spawning and managing several node.js
applications on a single server. It's an integral part of Nodejitsu's
production stack and is fully supported by a dedicated team of core node.js
<p>By installing haibu, a user creates a development environment for themselves
that mirrors the functionality of Nodejitsu's cloud platform! Any project that
can be deployed on Nodejitsu can be ran by haibu.</p>
<p>Haibu, which is Japanese for "hive", wraps node.js applications in a "carapace"
and converts them into managed "drones". This approach allows haibu to directly
interact with node.js applications and add all sorts of additional
functionality. Haibu also contains a plugin system, so you can easily add even
more functionality.</p>
<p>Haibu builds on this concept of "drones" and exposes a robust and granular API
for interacting with your node.js applications. At a low level, haibu's API is
exposed as a RESTFul HTTP webservice. Any system that supports basic HTTP
requests can communicate with a haibu server. If you are working in Node.js,
haibu comes with a high-level Node.js API client.</p>
<h2 id="Installation">Installation</h2>
<pre><code>[sudo] npm install haibu -g
<p>This will install haibu globally. You can also grab the source <a href="">directly from git</a>.</p>
<h2 id="Usage">Usage</h2>
<p>To start haibu, all you have to do is run <code>haibu</code>:</p>
<pre><code>$ haibu
__ __
/ /_ ______ __ / /_ __ __
/ __ \ / __ / / / / __ \ / / / /
/ / / / / /_/ / / / / /_/ / / /_/ /
/_/ /_/ \__,_/ /_/ /_/\___/ \__,_/
This is Open Source Software available under
the MIT License.
© 2010 Nodejitsu Inc.
All Rights Reserved -
haibu started @ on port 9002 as api-server
using plugins: config, exceptions, directories, log, http
<p>Haibu is an http server that exposes a REST api on port 9002. You can either
access this API client with a regular HTTP client, or use our <a href="">haibu-api</a> module. Unfortunately, jitsu does not work with haibu's HTTP API, only the nodejitsu API.</p>
<h2 id="Additional-Documentation">Additional Documentation</h2>
<p>For more documentation, visit haibu's <a href="">github page</a>.</p>
<div class='mp'>
<h1>Open Source Projects</h1>
<p><a name="opensource"></a></p>
<h2 id="Why-Open-Source">Why Open Source</h2>
<p>Most of Nodejitsu's technology stack is released as open source software. We
choose to do this for many reasons. Aside from being able to give back to the
Node.js community, releasing pieces of our stack as open-source allows other
developers to review and improve our software. We've already received invaluable
contributions to our platform from developers who would have never seen our code
if we had not open-sourced it.</p>
<h2 id="Where-To-Find-Our-Projects">Where To Find Our Projects</h2>
<p>Nodejitsu hosts its open-source projects on <a href="">Github</a>:</p>
<li><em><a href="" data-bare-link="true"></a></em>: Open source components of Nodejitsu's PaaS</li>
<li><em><a href="" data-bare-link="true"></a></em>: Nodejitsu's "anti-framework" for building web and cli applications</li>
<li><em><a href="" data-bare-link="true"></a></em>: A collection of node.js applications ready to use</li>
<p>Github is a web site for sharing and
collaborating on source code using <a href="">git</a>, a popular version
control system. You can get our source code without creating an account at
github, and if you want to create an account it's free. You will need a
<a href="">git client</a> if you wish to clone any of our
code repositories.</p>
<h2 id="How-To-Contribute">How To Contribute</h2>
<p>Anyone can contribute to any of our open-source projects at any time.
Our <a href="">github site</a> has the facilities for managing
patches, issues, code comments, version control, and just about anything else an
open source developer could need.</p>
<div class='mp'>
<h1>Frequently Asked Questions</h1>
<p><a name="faq"></a></p>
<p><strong>For more information about pricing, see <a href="">the pricing FAQ</a>.</strong></p>
<h2 id="-How-do-I-reset-my-password-">"How do I reset my password?"</h2>
<p>One way is to use jitsu. Simply type:</p>
<pre><code>jitsu users forgot :username
<p>where <code>:username</code> is your username. Alternately, go to <a href="" data-bare-link="true"></a> and click the "forgot password" link, where you will be prompted for your username. Either process will send you an email with further instructions.</p>
<h2 id="-Is-there-a-cheatsheet-somewhere-">"Is there a cheatsheet somewhere?"</h2>
<p>There sure is! Check out <a href="" data-bare-link="true"></a>.</p>
<h2 id="-How-are-programs-kept-alive-Do-I-need-to-use-Forever-">"How are programs kept alive? Do I need to use Forever?"</h2>
<p>Nodejitsu's cloud services watch your programs for you! You shouldn't have to do anything special to keep your apps running, much less use Forever.</p>
<h2 id="-How-can-I-make-my-app-use-a-port-other-than-port-80-">"How can I make my app use a port other than port 80?"</h2>
<p>Connecting to other servers using arbitrary ports requires no special considerations. However, <em>listening</em> for outside connections is currently limited to port 80 on the Nodejitsu platform because we require http host headers for domain name resolution of subdomains. Consequentially, each subdomain may only host one listening service.</p>
<p>The ability to host tcp applications on nodejitsu and listen on non-80 ports is on our roadmap but has no associated timeline.</p>
<h2 id="-How-can-I-turn-off-the-require-analyzer-in-jitsu-I-want-to-manage-my-own-dependencies-">"How can I turn off the require-analyzer in jitsu? I want to manage my own dependencies!"</h2>
<p>There are three ways to disable the require-analyzer:</p>
<li>Use the <code>--noanalyze</code> flag when running jitsu commands to disable it on a one-time basis.</li>
<li>Add <code>"analyze": false</code> to your package.json to disable it on a per-app basis.</li>
<li>Set "analyze" to <code>false</code> in your <code>~/.jitsuconf</code> to disable it on a global level.</li>
<h2 id="-How-Do-I-add-my-GitHub-repository-as-a-dependency-">"How Do I add my GitHub repository as a dependency?"</h2>
<p>Use the following format: <code></code></p>
<h2 id="-Why-won-t-this-C-addon-compile-">"Why won't this C++ addon compile?"</h2>
<p>Many <a href="">C++ addons</a> require libraries that are not included in Nodejitsu's infrastructure by default. For example, <a href="">node-canvas</a> requires <a href="">cairo</a>. Nodejitsu has cairo and many other such libraries, but may not have some more obscure ones.</p>
<h2 id="-How-do-I-specify-which-files-not-to-bundle-How-do-I-know-what-files-are-getting-bundled-">"How do I specify which files not to bundle? How do I know what files are getting bundled?"</h2>
<p>Jitsu uses npm to bundle files, meaning that jitsu bundles files in exactly the same manner than npm bundles published modules. You can read about this in <a href="">npm's documentation</a>.</p>
<p>In more detail: npm uses a file called <code>.npmignore</code>, which should contain a list of files and folders to ignore for the purpose of bundling. If this file does not exist, npm will use git's ignore file, called <code>.gitignore</code>, instead. This means that, if you want to bundle files that are ignored by git, you should create an <code>.npmignore</code> even if it's blank.</p>
<p>Finally, jitsu has the ability to bundle your app without deploying with the <code>jitsu package create</code> command. You can use this to make sure that the resulting .tgz file is as you expect.</p>
<div class='mp'>
<p><a name="support"></a></p>
<p>Nodejitsu has a team of developers standing by to assist users with any issues
they may come across while deploying and administrating their web applications
on the Nodejitsu platform. Nodejitsu strives to have a lightning-fast
turnaround on all issues you may have!</p>
<p>The following can be extremely helpful for the support team if you have them ahead of time:</p>
<li>A <a href="">gist</a> of your package.json file.</li>
<li>A <a href="">gist</a> of your command/action and error output.</li>
<li>Versions of tools and apps; <code>jitsu -v</code>, <code>node -v</code>, <code>npm -v</code>.</li>
<li>The platform you are working on--Linux, Mac, Windows, etc.</li>
<h2 id="E-mail">E-mail</h2>
<p>You can also contact us via email, at
<strong><a href=""></a></strong>.</p>
<h2 id="IRC-and-Kohai">IRC and Kohai</h2>
<p>Nodejitsu has a channel on freenode at
<a href="irc://" data-bare-link="true">irc://</a>
(<a href="" data-bare-link="true"></a>), where Nodejitsu
staff are standing by to support users around the clock. Drop by to ask
questions, get assistance, or even just to hang out!</p>
<p><a href="">Kohai</a> is an IRC bot that has some basic abilities
to help you among other features. To bring up his help dialogue just type <code>!help</code> into
the #nodejitsu channel and Kohai will message you.</p>
<h2 id="Github-Issues">Github Issues</h2>
<p>Each of Nodejitsu's open source projects uses Github Issues to manage bugs and
related software problems. Github Issues is most useful for developers. For
example, if a developer finds a bug in our open-source
<a href="">http proxy</a>, they can submit an
issue at <a href="" data-bare-link="true"></a> and tell us about
their bug.</p>
<div class='mp'>
<h1>Table of Appendices</h1>
<p><a name="apx"></a></p>
<li><a href="">package.json</a></li>
<li><a href="">Resources</a></li>
<li><a href="">Building The Handbook</a></li>
<div class='mp'>
<h1>Appendix: package.json</h1>
<p><a name="apx:package"></a></p>
<p><strong><a href=""></a> is an interactive package.json properties explorer! Highly recommended.</strong></p>
<h2 id="Understanding-the-package-json-format">Understanding the package.json format</h2>
<p>A package.json file describes your application, its dependencies, and other various application metadata. For a detailed spec on creating a package.json you can check out Isaac's fine documentation <a href="">here</a>.</p>
<h2 id="Preparing-a-package-json-for-your-application">Preparing a package.json for your application</h2>
<p>Nodejitsu requires that you create a valid <a href="#package_json" data-bare-link="true">package.json</a> for your application. The package.json will determine certain important pieces of information about your application which are required for deployment. Since sometimes it can get confusing when constructing your package.json file, we provide wizards in our CLI tool and on our website for creating one.</p>
<p>Here is an example of what your package.json might look like:</p>
"name": "hellonode",
"subdomain": "hellonode",
"scripts": {
"start": "node server.js"
"version": "0.0.0"
<p>Notice the "scripts" property? This is where you'll store information about specific scripts in your application. The "start" property indicates the script that will get called when your application is started. Usage is compatible with <code>npm start</code>.</p>
<h2 id="Specifying-dependencies-in-your-package-json">Specifying dependencies in your package.json</h2>
<p>If your application requires additional dependencies or third-party libraries, Nodejitsu fully supports npm module dependency resolution. All you have to do is list your dependencies the exact same way you would if you were packaging a module for npm. Here is an example of the same package.json with a few dependencies.</p>
"name": "hellonode",
"subdomain": "hellonode",
"scripts": {
"start": "server.js"
"dependencies": {
"async": "0.1.x",
"colors": "0.5.x",
"request": "1.9.x"
"version": "0.0.0"
<p>Your dependencies will be resolved when your application deploys to Nodejitsu.</p>
<h2 id="Nodejitsu-Specific-package-json-Properties">Nodejitsu-Specific package.json Properties</h2>
<p>A few package.json properties have special behavior on the Nodejitsu platform:</p>
<li><em>subdomain</em>: Specify the subdomain for your hosted app's nodejitsu url (for example, <code></code>.</li>
<li><em>domains</em>: A list of custom domains for your hosted app. See <a href="" data-bare-link="true"></a>.</li>
<li><em>env</em>: Specify environment variables for your app (for example, NODE_ENV="production" is set by default).</li>
<li><em>scripts.start</em>: This field is also used for <code>npm start</code>. However, nodejitsu's current implementation takes a path, whereas npm's implementation takes a shell command.</li>
<li><em>analyze</em>: Set this to "false" to force jitsu to not analyze for the app's dependencies.</li>
<div class='mp'>
<h1>Appendix: Resources</h1>
<p><a name="apx:resources"></a></p>
<p>New to Node.js? <strong>Don't be scared!</strong> There are plenty of resources out there
for beginners. Here are just a few:</p>
<li><a href="">The Official Docs</a> document
all of Node.js's core APIs.</li>
<li>The <a href="">Node.js Wiki</a> contains information
such as an FAQ, installation instructions, and lists of modules.</li>
<li>The #Node.js and #nodejitsu channels on
<a href=""></a> are ready to help you with any
Node.js issues and concerns you may have.</li>
<li><a href="!/NodeKohai">@NodeKohai on Twitter</a> is an irc bot that
shares Node.js tweets with the #nodejitsu irc channel. Ask it a quick question
and it just might give you an answer!</li>
<li><a data-bare-link="true" href=""></a> is a great place to check for modules that might
already solve your problem.</li>
<li><a data-bare-link="true" href=""></a> is a nodejitsu cheatsheet listing the most common commands.</li>
<li><a data-bare-link="true" href=""></a> is an interactive reference for the package.json format.</li>
<li><a data-bare-link="true" href=""></a> is a quick cheatsheet for npm commands.</li>
<div class='mp'>
<h1>Appendix: Building the Nodejitsu Handbook</h1>
<p><a name="apx:build"></a></p>
<h2 id="Dependencies">Dependencies</h2>
<p>The build process for the handbook has a few dependencies:</p>
<li><a href="">make</a></li>
<li><a href="">ronn</a></li>
<li><a href="">htmldoc</a></li>
<p>Make and htmldoc should be available via your operating system's package manager
(ie. apt-get). ronn is available on <a href="">rubygems</a>, which in
turn should be available via your operating system's package manager as well. On
Debian-based systems, the rubygems package does not add its bin folder
(<code>/var/lib/gems/1.8/bin</code>) to your $PATH variable, so add something
<p>to the end of your <code>~/.profile</code> file and activate it by running <code>. ~/.profile</code>.</p>
<h2 id="Build-Process">Build Process</h2>
<p>Once you've installed the dependencies, all you have to do is:</p>
<pre><code>$ make
<p>and the files <code>./</code>, <code>book.pdf</code>, <code>book.html</code>, <code></code> and <code></code>
should all be generated.</p>
Jump to Line
Something went wrong with that request. Please try again.