Created
October 7, 2012 04:54
-
-
Save mkuklis/3847147 to your computer and use it in GitHub Desktop.
bring redis up/down for testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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