• Stars
    star
    722
  • Rank 62,738 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated almost 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[Deprecated] a node.js application server - spawn your own node.js clouds, on your own hardware

haibu

Deprecated

We deprecated Haibu on 27th of August, 2013. We hosted a goodbye party and all that. To be honest, no tears were shed.

We moved to an agentless infrastrucure described in detail in this blog post.

Haibu is dead, long live Haibu!

spawn your own node.js clouds, on your own hardware

What is haibu?

haibu is the open-source node.js project used at Nodejitsu's for spawning and managing several node.js applications on a single server. It's an integral part of our production stack and is fully supported.

How does it work?

haibu (which is Japanese for "hive") recieves commands for spawning, transforming, and managing multiple node.js applications. Haibu utilizes a unique approach by wrapping spawned Node.js applications in a "Carapace" which allows haibu to extend spawned applications with all sorts of additional functionaltiy. When haibu wraps a node.js application in a "carapace" the application becomes a "drone".

This approach allows haibu to directly interact with node.js applications and add all sorts of additional functionality. Carapace also contains a plugin system including functionality for things like: chroot, chdir, and node's built-in IPC.

Where can I run haibu?

haibu doesn't discriminate. If your environment supports node.js, you can install haibu and start up your own node.js cloud. This makes haibu an ideal tool for both development purposes and production usage since you can seamlessly setup haibu on your local machine, on utility computing providers (such as Amazon EC2 or Rackspace), on dedicated servers, or even on a mobile phone!

Installation

[sudo] npm install haibu -g

An overview of using haibu

Starting up a haibu

[sudo] node bin/haibu
(...)
haibu started @ 127.0.0.1 on port 9002 as api-server

Now that there is a haibu server running, we can begin to interact with it's API.

##Starting an application using the haibu Client (From: /examples/hello-spawn.js)

Allows you to call haibu programmatically from inside your node.js scripts.

var eyes = require('eyes'),
    haibu = require('haibu');

// Create a new client for communicating with the haibu server
var client = new haibu.drone.Client({
  host: 'localhost',
  port: 9002
});

// A basic package.json for a node.js application on haibu
var app = {
   "user": "marak",
   "name": "test",
   "domain": "devjitsu.com",
   "repository": {
     "type": "git",
     "url": "https://github.com/Marak/hellonode.git",
   },
   "scripts": {
     "start": "server.js"
   }
};

// Attempt to start up a new application
client.start(app, function (err, result) {
  if (err) {
    console.log('Error spawning app: ' + app.name);
    return eyes.inspect(err);
  }

  console.log('Successfully spawned app:');
  eyes.inspect(result);
});


client.start(app, function (err, result) {
  eyes.inspect(err);
  eyes.inspect(result);
});

Push deploy

cd path/to/your/app
tar -cz . | curl -XPOST -sSNT- localhost:9002/deploy/username/appname
# or, like this:
tar -czf app.tgz .
curl -XPOST -sSNT app.tgz localhost:9002/deploy/username/appname

NOTE: you will need to invoke tar -czf app.tgz . inside your app's directory else it will add directories inside the tarball that will confuse haibu. haibu only accepts gzip format.

or, programmatically:

  var request = require('request')
    , fs = require('fs');
    
  fs.createReadStream(tarball)
    .pipe(request.put({url: 'http://localhost:9002/deploy/username/appname'}, function (err, res, body) {
      var result = JSON.parse(body) //app information
    })
  

RESTful Webservice

If you need to integrate non-node.js systems with haibu, you can use haibu's RESTful JSON API. We recommend using haibu's native Node.js Client, but if you need to integrate with non-node.js systems this is not always a viable option.

Starting an application through the webservice

POST http://127.0.0.1:9002/drones/test/start
...
{
    "start": {
        "user": "marak",
        "name": "test",
        "domain": "devjitsu.com",
        "repository": {
            "type": "git",
            "url": "https://github.com/Marak/hellonode.git"
        },
        "scripts": {
            "start": "server.js"
        }
    }
}

Response

HTTP/1.1 200 OK
Date: Thu, 05 May 2011 18:15:36 GMT
Server: journey/0.4.0
Content-Type: application/json
Content-Length: 353
Connection: close
...
{
    drone: {
        uid: 'gbE3',
        ctime: 1304619335818,
        pid: 7903,
        foreverPid: 7195,
        options: [ '/Users/Charlie/Nodejitsu/haibu/local/marak/test/hellonode/server.js', '127.0.0.1', 8001 ],
        file: '/Users/Charlie/Nodejitsu/haibu/bin/carapace',
        pidFile: '/Users/Charlie/.forever/pids/gbE3.pid',
        port: 8001,
        host: '127.0.0.1'
    }
}

Stopping an application through the webservice

POST http://127.0.0.1:9002/drones/test/stop
...
{
    "stop": {
        "name": "test"
    }
}

response

HTTP/1.1 200 OK
Date: Thu, 05 May 2011 18:16:22 GMT
Server: journey/0.4.0
Connection: close
Transfer-Encoding: chunked

##Package.json settings

Haibu uses a package.json format extension in order to determine what to deploy. Also, haibu is a pull based server; this means that it will pull files from outside of the server in order to deploy instead of using uploading directly into the process.

###Name

The name attribute is required and will represent the name of the application being deployed.

{
  "name": "app-name"
}

###User

The user attribute is required and will represent the user who started up a drone.

{
  "user": "myusername"
}

###Repositories

git

This type of repository will pull a git repository into haibu and deploy its contents.

{
  "repository": {
    "type": "git",
    "url": "http://path/to/git/server"
  }
}

local

This type of repository will pull a directory relative to the haibu and deploy its contents.

{
  "repository": {
    "type": "local",
    "directory": "/path/to/application"
  }
}

tar

This type of repository will pull a remote archive relative to the haibu and deploy its contents.

{
  "repository": {
    "type": "tar",
    "url": "http://path/to/archive.tar"
  }
}

zip

This type of repository will pull a remote archive relative to the haibu and deploy its contents.

{
  "repository": {
    "type": "zip",
    "url": "http://path/to/archive.zip"
  }
}

npm

This type of repository will install a npm package as application. The package will be available as directory under its name and the scripts will be installed in the .bin directory. So scripts.start should have one of both as relative directory:

"scripts": {
  "start": ".bin/server.js"
}

or:

"scripts": {
  "start": "name of npm package/server.js"
}
{
  "repository": {
    "type": "npm",
    "package": "name of npm package"
  }
}

Run Tests

All of the haibu tests are written in vows, and cover all of the use cases described above.

  $ npm test

If you wish to take advantage of all of the configuration offered in haibu through flatiron see the sample test-config.json.example configuration file.

If you copy and paste the above link, the test suite will attempt to connect to Rackspace for some of the remote file tests. You don't need to run these tests or use Rackspace to get started. We'll be improving our test runner soon to help make this process a bit more intuitive.

FAQ

jitsu is not working with haibu

jitsu is intended to work with the full production stack at Nodejitsu and should not be used with haibu.

Author: Nodejitsu Inc.

More Repositories

1

jitsu

Flawless command line deployment of your Node.js apps to the cloud
JavaScript
648
star
2

handbook

A gentle introduction to the art of Nodejitsu
JavaScript
473
star
3

nexpect

spawn and control child processes in node.js with ease
JavaScript
290
star
4

godot

Godot is a streaming real-time event processor based on Riemann written in Node.js
JavaScript
265
star
5

docs

Community powered rocket fuel for node.js
JavaScript
194
star
6

node-cloudservers

A client implementation for Rackspace CloudServers in node.js
JavaScript
159
star
7

require-analyzer

Determine the set of requirements for a given node.js file, directory tree, or module
JavaScript
152
star
8

node-cloudfiles

A client implementation for Rackspace CloudFIles in node.js
JavaScript
151
star
9

kohai

I am kohai. I am a pluggable irc bot for managing real-time data events.
JavaScript
91
star
10

prenup

A collaborative bdd project planning tool for node. uses kyuri and VowsJS
JavaScript
83
star
11

module-foundry

A web service for building node.js modules that runs on Linux, SmartOS and Windows.
JavaScript
80
star
12

mock-request

A simple testing tool for mocking HTTP sequences of request / response pairs in node.js
JavaScript
77
star
13

haibu-carapace

The application host used by the haibu node.js application deployment / management server.
JavaScript
69
star
14

txn

Process and update CouchDB data in atomic, all-or-nothing transactions
JavaScript
65
star
15

nodejitsu-api

a collection of client wrappers for nodejitsu's core api
JavaScript
47
star
16

browsenpm.org

Browse packages, users, code, stats and more the public npm registry in style.
JavaScript
44
star
17

forza

A lightweight agent for Godot
C
36
star
18

jitsu-ui

A terminal interface for jitsu.
JavaScript
34
star
19

aeternum

A process monitor in libuv
C
31
star
20

module-smith

A simple extensible npm build bot that works on Linux, SmartOS, and Windows.
JavaScript
19
star
21

solenoid

Jump start an application
JavaScript
19
star
22

overwatch

A deterministic couchdb replication watcher
JavaScript
19
star
23

persistent-ghost

Wrapper to deploy the Ghost blog on Nodejitsu
JavaScript
18
star
24

haibu-api

A collection of client wrappers for haibu's core api
JavaScript
11
star
25

defaultable

Transparent, drop-in helper for overridable, inheritable defaults in CommonJS modules
JavaScript
9
star
26

contour

Collection of BigPipe Pagelets for fast prototyping and scaffold of templates
CSS
8
star
27

npm-pkg-top

Lists the top binary packages by npm stars and github stars
JavaScript
7
star
28

npm-ev-source

The transform module or daemon that takes a `skimdb` based couch and turns it into an `event-sourced` complete npm
JavaScript
7
star
29

packages-pagelet

A pagelet for rendering a npm package page.
JavaScript
4
star
30

npm-package-json-pagelet

An interactive guide for package.json
HTML
3
star
31

npm-search-pagelet

Search the npm registry.
JavaScript
2
star
32

nodejitsu-npm

A simple command line utility to get started with a Nodejitsu Private npm!
JavaScript
2
star
33

npm-dependencies-pagelet

Pagelet for the dependencies UI for a single package
JavaScript
1
star
34

registry-status-pagelet

Pagelet for visual overview of npm registry statuses
JavaScript
1
star
35

service-select

Service selector pagelet for selecting
JavaScript
1
star
36

npm-documentation-pagelet

Display documentation of npm
CSS
1
star