/** * @class * @param {Object} options - see {@link EggApplication} */ constructor(options = {}) { options.type = 'agent'; super(options); this.loader.load(); // dump config after loaded, ensure all the dynamic modifications will be recorded const dumpStartTime = Date.now(); this.dumpConfig(); this.coreLogger.info('[egg:core] dump config after load, %s', ms(Date.now() - dumpStartTime)); // keep agent alive even it doesn't have any io tasks setInterval(() => {}, 24 * 60 * 60 * 1000); this._uncaughtExceptionHandler = this._uncaughtExceptionHandler.bind(this); process.on('uncaughtException', this._uncaughtExceptionHandler); }
/** * @class * @param {Object} options - see {@link EggApplication} */ constructor(options = {}) { options.type = 'application'; super(options); // will auto set after 'server' event emit this.server = null; try { this.loader.load(); } catch (e) { // close gracefully this[CLUSTER_CLIENTS].forEach(cluster.close); throw e; } // dump config after loaded, ensure all the dynamic modifications will be recorded const dumpStartTime = Date.now(); this.dumpConfig(); this.coreLogger.info('[egg:core] dump config after load, %s', ms(Date.now() - dumpStartTime)); this[WARN_CONFUSED_CONFIG](); this[BIND_EVENTS](); }
this.dumpConfig(); this.dumpTiming(); this.coreLogger.info('[egg:core] dump config after ready, %s', ms(Date.now() - dumpStartTime)); })); this._setupTimeoutTimer();
setInterval(function () { self.shoot().catch(self.onerror); // 捕获 error 时间 }, ms('1s'));
function msOption (name, value) { const n = typeof value === 'number' ? value : parseMs(value) if (!Number.isInteger(n)) { throw new Error('The "' + name + '" option must be an integer, optionally with a unit (e.g. "50ms")') } if (n <= 0) throw new Error('The "' + name + '" option must be > 0 milliseconds') return n }
constructor(fetchfunction, options) { super((options && options.limit ) || 500000); this.fetch = fetchfunction; this.ttl = (options && options.ttl) || ms('5m'); this.materialize = function (getObj) { debug('materializing', getObj); return fetchfunction(getObj.table, getObj); }; this.generateKey = function(keyObj) { return [keyObj.table, keyObj.row, keyObj.maxVersions, keyObj.timeRange, keyObj.columns.map(cell => cell.family + ":" + cell.qualifier).sort().join(","), Object.entries(keyObj.columnTypes).map(keyValue => keyValue.join(":")).sort().join(",")].join("."); } }
static _getJWTExpireTime() { return new Date(new Date().getTime() + ms(JWT_CONFIG.expiresIn)).toISOString(); }
test('writes to a fallback directory if AWS upload failed (e.g. no bucket param)', async t => { const customTransport = nodemailer.createTransport({ jsonTransport: true }); customTransport.use( 'compile', base64ToS3({ maxAge: ms('1d') }) ); const res = await customTransport.sendMail({ html: html.png, subject: 'subject', to: 'niftylettuce@gmail.com', from: 'niftylettuce@gmail.com' }); const message = JSON.parse(res.message); const $ = cheerio.load(message.html); t.true( validator.isURL($('img').attr('src'), { protocols: ['file'], require_host: false }) ); });
setInterval(function () { self.update() }, interval ? ms(interval) : DEFAULT_REFRESH_INTERVAL)
headers[cfgTokenOutboxHeader] = cfgTokenOutboxPrefix + opt_Authorization; let connectionAndInactivity = optTimeout && optTimeout.connectionAndInactivity && ms(optTimeout.connectionAndInactivity); var options = {uri: urlParsed, body: postData, encoding: 'utf8', headers: headers, timeout: connectionAndInactivity}; setTimeout(function() { raiseError(ro, 'ETIMEDOUT', 'Error whole request cycle timeout'); }, ms(optTimeout.wholeCycle));
.setTitle("🔒 Channel locked down") .setColor(16753762) .setDescription(`\`\`\`ruby\nChannel: #${message.channel.name} (${message.channel.id})\nDuration: ${ms(ms(time), { long: true })}\nIssued by: ${message.author.tag}\`\`\``) .setFooter(texts.moderation.poweredBy, this.client.user.displayAvatarURL) .setTimestamp(); .then(message.channel.send("Lockdown lifted.")); delete this.client.lockit[message.channel.id]; }, ms(time)); }); });
static _getExpireTime() { return new Date(new Date().getTime() + ms(AWS_EXPIRE_TIME)).toISOString(); }
setInterval(function () { self.shoot().catch(self.onerror); // 捕获 error 时间 }, ms('1s'));
headers[cfgTokenOutboxHeader] = cfgTokenOutboxPrefix + opt_Authorization; let connectionAndInactivity = optTimeout && optTimeout.connectionAndInactivity && ms(optTimeout.connectionAndInactivity); var options = {uri: urlParsed, body: postData, encoding: 'utf8', headers: headers, timeout: connectionAndInactivity}; setTimeout(function() { raiseError(ro, 'ETIMEDOUT', 'Error whole request cycle timeout'); }, ms(optTimeout.wholeCycle));