d.run(function() { if(process.env.NODE_ENV!='development') { io.adapter(redis({ host: appConfig.redis.getConfig().host, port: appConfig.redis.getConfig().port })); } io.on('connection', onConnect); });
exports.quit = function () { registry.redis_sessions.quit(); registry.redis.quit(); registry.redis_pub.quit(); registry.redis_sub.quit(); nohm_redis_client.quit(); }
worker.on('success', async () => { expect(loggedErrors.length).toBe(1) let length = await specHelper.redis.llen('resque_test:failed') expect(length).toBe(0) await worker.end() resolve() })
beforeEach(function (done) { Queue = kue.createQueue({ redis: { db: 2 // custom db } }); redisPublishClient = kue.redis.createClient(); done(); });
async () => { const enqueue = await queue.enqueue(specHelper.queue, 'blockingJob', [1, 2]) expect(enqueue).toBe(true) await worker.start() await worker.end() const result = await specHelper.redis.keys(specHelper.namespace + ':lock*') expect(result).toHaveLength(0) }
test('will remove a lock on a job when the job has been worked', async () => { const enqueue = await queue.enqueue(specHelper.queue, 'uniqueJob', [1, 2]) expect(enqueue).toBe(true) await worker.start() await worker.end() const result = await specHelper.redis.keys(specHelper.namespace + ':lock*') expect(result).toHaveLength(0) })
scheduler.on('cleanStuckWorker', async (workerName, errorPayload, delta) => { // response data should contain failure expect(workerName).toEqual(worker.name) expect(errorPayload.worker).toEqual(worker.name) expect(errorPayload.error).toEqual('Worker Timeout (killed manually)') // check the workers list, should be empty now expect(await queue.allWorkingOn()).toEqual({}) // check the failed list let failed = await specHelper.redis.rpop(specHelper.namespace + ':' + 'failed') failed = JSON.parse(failed) expect(failed.queue).toBe('stuckJobs') expect(failed.exception).toBe('Worker Timeout (killed manually)') expect(failed.error).toBe('Worker Timeout (killed manually)') scheduler.removeAllListeners('cleanStuckWorker') resolve() })
self._tvdbRequest('/GetSeries.php?seriesname='+encodeURIComponent(name), function (err, doc) { if (err) { callback(err); } else { var multi = redis.multi(); var arr = doc.find('//Series').map(function (serie) { var values = { name: getText(serie.get('SeriesName')), description: getText(serie.get('Overview')), id: getText(serie.get('seriesid')), first_aired: getText(serie.get('FirstAired')) }; multi.rpush(set_key, JSON.stringify(values)); return values; }); multi.expire(set_key, 60*60); // expire in one hour multi.exec(); callback(null, arr); } });
searchSeries: function (name, callback) { var self = this; var set_key = 'temp_tvdb_cache:getseries:'+name; var redis = require(__dirname+'/../registry.js').redis; redis.lrange(set_key, 0, -1, function (err, series) { if (err || series.length === 0) { self._tvdbRequest('/GetSeries.php?seriesname='+encodeURIComponent(name), function (err, doc) { if (err) { callback(err); } else { var multi = redis.multi(); var arr = doc.find('//Series').map(function (serie) { var values = { name: getText(serie.get('SeriesName')), description: getText(serie.get('Overview')), id: getText(serie.get('seriesid')), first_aired: getText(serie.get('FirstAired')) }; multi.rpush(set_key, JSON.stringify(values)); return values; }); multi.expire(set_key, 60*60); // expire in one hour multi.exec(); callback(null, arr); } }); } else { callback(null, series.map(function (item) { try { return JSON.parse(item); } catch (e) { } })); } }); },
test('should stat with no redis keys in the namespace', async () => { let keys = await specHelper.redis.keys(specHelper.namespace + '*') expect(keys.length).toBe(0) })
function UserRedis(){ model.redis.call(this); };
d.run(function() { io.adapter(redis({ host: appConfig.redis.getConfig().host, port: appConfig.redis.getConfig().port })); io.on('connection', onConnect); });
var redis = require('redis'); var nohm = require(__dirname+'/../../lib/nohm').Nohm; var args = require(__dirname+'/../testArgs.js'); nohm.setPrefix(args.prefix); args.redis.on('ready', function () { nohm.setClient(args.redis); }); require(__dirname+'/Model.js'); process.on('message', function (msg) { var event, modelName, fn; switch (msg.question) { case 'does nohm have pubsub?': process.send({ question: msg.question, answer: nohm.getPubSubClient() }); break; case 'initialize': nohm.setPubSubClient(redis.createClient(args.redis_port, args.redis_host), function (err) { process.send({ question: msg.question, answer: err || true, error: err }); }); break;
client.on("error", function (err) { console.error("Error connecting redis ("+appConfig.redis.getConfig().host+" port "+appConfig.redis.getConfig().port+")"); });
var phridge = require('phridge'), redis = require("redis"); var TTL_CACHE_SEO = 60 * 60 * 24; //1 day var htmlcleaner = require(__dirname+'/htmlcleaner'), status = require(__dirname+'/status'), appConfig = require(__dirname+'/../../config');//, //translateSeo = require(__dirname+'/translate-seo'); var client = redis.createClient(appConfig.redis.getConfig().port, appConfig.redis.getConfig().host); client.on("error", function (err) { console.error("Error connecting redis ("+appConfig.redis.getConfig().host+" port "+appConfig.redis.getConfig().port+")"); }); var bots = [ //FACEBOOK 'facebookexternalhit/1.http (+0://www.facebook.com/externalhit_uatext.php)', 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)', 'Facebot', //SLACK 'Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)', 'Slack-ImgProxy 0.19 (+https://api.slack.com/robots)', 'Slackbot 1.0(+https://api.slack.com/robots)', //TWITTER 'Twitterbot/1.0', //PINTEREST 'Pinterest/0.1 +http://pinterest.com/',
exports.connect = function (cb) { nohm_redis_client = redis.createClient(config.nohm.port, config.nohm.host, { no_ready_check: true }); nohm_redis_client.on('error', function () { console.log('nohm redis error: ', arguments); }); registry.redis_sessions = redis.createClient(config.redis.port, config.redis.host, { no_ready_check: true }); registry.redis_sessions.on('error', function () { console.log('redis error: ', arguments); }); registry.redis = redis.createClient(config.redis.port, config.redis.host, { no_ready_check: true }); registry.redis.on('error', function () { console.log('redis error: ', arguments); }); registry.redis_pub = redis.createClient(config.redis.port, config.redis.host, { no_ready_check: true }); registry.redis_pub.on('error', function () { console.log('redis error: ', arguments); }); registry.redis_sub = redis.createClient(config.redis.port, config.redis.host, { no_ready_check: true }); registry.redis_sub.on('error', function () { console.log('redis error: ', arguments); }); var noop = function () {}; var authAndSelect = function (client, db, pw) { return function (cb) { if (pw) { client.auth(pw, function (err) { if (err) { cb(err) } else { client.select(db || 0, cb); } cb = noop; }); } else { client.select(db || 0, cb); cb = noop; } } } async.series([ authAndSelect(registry.redis_sessions, config.sessions.db, config.redis.pw), authAndSelect(registry.redis, config.redis.db, config.redis.pw), authAndSelect(registry.redis_pub, config.redis.db, config.redis.pw), authAndSelect(registry.redis_sub, config.redis.db, config.redis.pw), authAndSelect(nohm_redis_client, config.nohm.db, config.nohm.pw) ], function (err) { if (err) { return console.log('Error: failed initialization while authing/selecting a redis DB ', err); } nohm.setClient(nohm_redis_client); nohm.setPrefix(config.nohm.prefix); cb(); } ); };