1.1.2 • Published 8 years ago
cassandra-installer v1.1.2
Cassandra Installer
This package is a utility that provides the ability to use Cassandra in an embedded way for your node.js applications. The process works as follows:
- Select the package version of cassandra
- Download Cassandra (It will fetch from the nearest mirror)
- Install cassandra
- Start Cassandra
- Stop Cassandra
- Configure your logger instance for the module
Example Usage
'use strict';
const CassandraInstaller = require('cassandra-installer'),
winston = require('winston');
/* Create the logging levels, if none provided it will revert to the default console logger */
var transports = [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: '/tmp/cassandra-installer.log' })
];
var options = {
destination : '/tmp',
version : '3.5',
dbName : 'test_db',
transports : transports
};
/* Create a new installer that will download cassandra 3.4 in /tmp */
var installer = new CassandraInstaller(options);
/* Download cassandra */
installer.download((err, data) => {
/* Install cassandra */
installer.install((err, data) => {
/* Start cassandra */
installer.start();
/* Create the keyspace that was defined in option */
installer.createKeyspace(err =>{
/* Drop the db */
installer.dropKeyspace(err => {
/* Stop cassandra */
installer.stop();
/*Cleanup */
setTimeout(function() { //allow 10 seconds for cassandra to shutdown gracefully
installer.uninstall(err => {
if(err) console.log(err);
});
}, 10000);
});
);
});
});
Note : Make sure you have the Java runtime 1.8.x installed so that Cassandra runs.
This module works on MacOS X and all flavors of *nix