Skip to content

Instantly share code, notes, and snippets.

@chrisjaure
Created July 29, 2012 17:16
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisjaure/3200336 to your computer and use it in GitHub Desktop.
Save chrisjaure/3200336 to your computer and use it in GitHub Desktop.
Deploying nodejs apps with haibu and git
#! /path/to/node
var haibu = require('/path/to/haibu');
var client = new haibu.drone.Client();
process.stdin.resume();
process.stdin.on('data', function(data){
var package = JSON.parse(data.toString());
package.repository = {
type: "git",
url: "/path/to/dir/containing/repos/"+package.name+".git"
};
client.get(package.name, function(err){
if (!err) {
client.stop(package.name, function(){
client.clean(package, function(){
client.start(package, function(err, result){
if (err) {
console.log('Error', err);
return;
}
console.log("Client updated! " + package.name + " running at " + result.drone.port );
});
});
});
}
else {
client.start(package, function(err, result){
if (err) {
console.log('Error', err);
return;
}
console.log("Success! " + package.name + " running at " + result.drone.port );
});
}
});
});

Deploying nodejs apps with haibu and git

Git Set-Up

Make a bare git repo on your server. I follow these instructions. Add the post-receive hook.

Deploy Set-Up

Install node and haibu. Start haibu. Drop deploy.js somewhere. Push with git on your local machine to your server. Done!

#! /usr/bin/env bash
git show master:package.json | /path/to/deploy.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment