Skip to content

Instantly share code, notes, and snippets.

@mkuklis
Created October 7, 2012 04:54
Show Gist options
  • Save mkuklis/3847147 to your computer and use it in GitHub Desktop.
Save mkuklis/3847147 to your computer and use it in GitHub Desktop.
bring redis up/down for testing
var exec = require('child_process').exec;
var redis = require("redis");
var when = require('when');
var client;
exports.startServer = function () {
exec('redis-server');
}
exports.stopServer = function () {
client && client.shutdown();
}
exports.createClient = function () {
var deffered = when.defer();
if (client) {
deffered.resolve(client);
}
else {
client = redis.createClient();
client.on('connect', function () {
deffered.resolve(client);
});
}
return deffered;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment