1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00
This commit is contained in:
Ruben Bridgewater
2016-04-01 16:58:13 +02:00
parent 500c5acb3a
commit 218c0b35d7
5 changed files with 36 additions and 24 deletions

View File

@@ -49,31 +49,29 @@ module.exports = {
start: function (done, conf, port) {
// spawn redis with our testing configuration.
var confFile = conf || path.resolve(__dirname, '../conf/redis.conf');
var redis = process.platform === 'win32' ? 'redis-64\\tools\\redis-server.exe' : 'redis-server';
var redis = 'redis-server';
if (process.platform === 'win32') {
confFile = confFile.replace('.conf', '.win32.conf');
redis = 'redis-64\\tools\\redis-server.exe';
}
var rp = spawn.sync(redis, [confFile], { stdio: 'inherit' });
// wait for redis to become available, by
// checking the port we bind on.
waitForRedis(true, function () {
// return an object that can be used in
// an after() block to shutdown redis.
return done(null, {
spawnFailed: function () {
return false;
},
stop: function (done) {
rp.once('exit', function (code) {
var error = null;
if (code !== null && code !== 0) {
error = new Error('Redis shutdown failed with code ' + code);
}
waitForRedis(false, function () {
return done(error);
}, port);
});
rp.kill('SIGTERM');
}
});
}, port);
done(null, {
spawnFailed: function () {
return false; // Remove if as soon as it's not necessary anymore
},
stop: function (done) {
rp.once('exit', function (code) {
var error = null;
if (code !== null && code !== 0) {
error = new Error('Redis shutdown failed with code ' + code);
}
waitForRedis(false, function () {
return done(error);
}, port);
});
rp.kill('SIGTERM');
}
});
}
};