Stop the process when expire-channels is done

pull/1/head
yflory 7 years ago
parent f004c4d701
commit ef0c08130d

@ -78,7 +78,7 @@ nt = nThen(function (w) {
store = _store; store = _store;
})); }));
}).nThen(function () { }).nThen(function () {
dirs.forEach(function (dir) { dirs.forEach(function (dir, dIdx) {
queue(function (w) { queue(function (w) {
console.log('recursing into %s', dir); console.log('recursing into %s', dir);
Fs.readdir(Path.join(root, dir), w(function (e, list) { Fs.readdir(Path.join(root, dir), w(function (e, list) {
@ -98,6 +98,11 @@ nt = nThen(function (w) {
}); });
}); });
}); });
if (dIdx === (dirs.length - 1)) {
queue(function () {
store.shutdown();
});
}
})); }));
}); });
}); });

@ -418,6 +418,7 @@ module.exports.create = function (
openFileLimit: conf.openFileLimit || 2048, openFileLimit: conf.openFileLimit || 2048,
}; };
// 0x1ff -> 777 // 0x1ff -> 777
var it;
Fs.mkdir(env.root, 0x1ff, function (err) { Fs.mkdir(env.root, 0x1ff, function (err) {
if (err && err.code !== 'EEXIST') { if (err && err.code !== 'EEXIST') {
// TODO: somehow return a nice error // TODO: somehow return a nice error
@ -465,9 +466,12 @@ module.exports.create = function (
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
clearChannel(env, channelName, cb); clearChannel(env, channelName, cb);
}, },
shutdown: function () {
clearInterval(it);
}
}); });
}); });
setInterval(function () { it = setInterval(function () {
flushUnusedChannels(env, function () { }); flushUnusedChannels(env, function () { });
}, 5000); }, 5000);
}; };

Loading…
Cancel
Save