Haibu Drone's Little Shell
Carapace is an process wrapper for Node.js applications that is part of the Haibu Network. Carapace also provides a Hook.IO based plugin system to simplify deployment and development of applications.
By utilizing Carapace you can help automate deployments of applications into a custom environment. Combining Carapace with the Forever Daemon can allow you run the application in the environment indefinitely.
curl http://npmjs.org/install.sh | sh
[sudo] npm install carapace
# run the included shell script in a terminal
sudo ./examples/jailedserver
# then on another terminal poke the server using `curl` and `watch`
watch 'curl http://localhost:1337'
code is available in ./examples/jailer.js
and must be ran with superuser privileges
var carapace = require('../lib/carapace');
var script = 'server.js',
hookOpts = {
'debug' : false,
'hook-port' : 5061
},
scriptPort = 31337;
carapace.listen( hookOpts,function () {
carapace.on('carapace::plugin::error', function (info) {
console.log('Error loading plugin: ' + info.plugin);
console.log(info.error.message);
console.dir(info.error.stack.split('\n'))
});
carapace.use([
carapace.plugins.heartbeat,
carapace.plugins.chroot,
carapace.plugins.chdir
], function () {
carapace.chroot('./examples/chroot-jail', console.log.bind(null, 'hello'));
carapace.chdir('.');
carapace.run(script, ['--port', scriptPort], function afterRun() {
carapace.heartbeat(function () {
console.log('bump'.red);
},1000);
console.log(script.yellow + ' running on port '.grey + scriptPort.toString().green);
});
});
});
# Run the above code in a terminal with
sudo node ./examples/jailer.js
# Poke the server in another terminal with
watch 'curl http://localhost:31337'
carapace [hook-options] --plugin [plugin] --[plugin] [options] application [options]
--hook-port [port]
--hook-host [hostname]
Carapace's Plugin Manager's Listening port/hostname
--plugin [plugin]
Plugin to use with the carapace instance
--[plugin] [options]
Option to be passed to the [plugin]
[application] [application's CLI options]
Any options that isn't consumed by the Carapace will automatically be passed to the application
List of known plugins, and options (if any) used by them
- chroot - directory to rebind as root directory '/'
- chdir - directory to change into
- heartbeat - time in micro-seconds between 'carapace::heartbeat' events
All of the carapace
tests are written in vows
$ npm test