Skip to content

Instantly share code, notes, and snippets.

@skeeet
Forked from chrisjaure/deploy.js
Created Aug 22, 2013
Embed
What would you like to do?
#! /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