Merge branch 'develop' into api-v3 and move new relic to new location

This commit is contained in:
Matteo Pagliazzi
2016-02-22 11:43:35 +01:00
437 changed files with 11185 additions and 9620 deletions
+14 -11
View File
@@ -2,27 +2,30 @@
require('babel-core/register');
// Only do the minimal amount of work before forking just in case of a dyno restart
var cluster = require('cluster');
var nconf = require('nconf');
var logger = require('./libs/api-v3/logger');
const cluster = require('cluster');
const nconf = require('nconf');
const logger = require('./libs/api-v3/logger');
// Initialize configuration
var setupNconf = require('./libs/api-v3/setupNconf');
const setupNconf = require('./libs/api-v3/setupNconf');
setupNconf();
var IS_PROD = nconf.get('IS_PROD');
var IS_DEV = nconf.get('IS_DEV');
var cores = Number(nconf.get('WEB_CONCURRENCY')) || 0;
const IS_PROD = nconf.get('IS_PROD');
const IS_DEV = nconf.get('IS_DEV');
const CORES = Number(nconf.get('WEB_CONCURRENCY')) || 0;
// Initialize New Relic
if (IS_PROD) require('newrelic');
// Setup the cluster module
if (cores !== 0 && cluster.isMaster && (IS_DEV || IS_PROD)) {
if (CORES !== 0 && cluster.isMaster && (IS_DEV || IS_PROD)) {
// Fork workers. If config.json has CORES=x, use that - otherwise, use all cpus-1 (production)
for (var i = 0; i < cores; i += 1) {
for (let i = 0; i < CORES; i += 1) {
cluster.fork();
}
cluster.on('disconnect', (worker) => {
var w = cluster.fork(); // replace the dead worker
cluster.on('disconnect', function onWorkerDisconnect (worker) {
let w = cluster.fork(); // replace the dead worker
logger.info('[%s] [master:%s] worker:%s disconnect! new worker:%s fork', new Date(), process.pid, worker.process.pid, w.process.pid);
});
-2
View File
@@ -169,8 +169,6 @@ module.exports.analytics = { track: function() { }, trackPurchase: function() {
module.exports.setupConfig = function(){
if (nconf.get('IS_DEV'))
Error.stackTraceLimit = Infinity;
//if (nconf.get('IS_PROD'))
//require('newrelic');
var analytics = IS_PROD && require('./api-v2/analytics');
var analyticsTokens = {
+20
View File
@@ -0,0 +1,20 @@
// We can't rely on babel here
// because the file is requested directly by the new relic module
const nconf = require('nconf');
// IMPORTANT remember to set the location of this file using the NEW_RELIC_HOME env variable
// more info here https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration
exports.config = {
app_name: ['Habitica'], // eslint-disable-line camelcase
license_key: nconf.get('NEW_RELIC_LICENSE_KEY'), // eslint-disable-line camelcase
logging: {
/**
* Level at which to log. 'trace' is most useful to New Relic when diagnosing
* issues with the agent, 'info' and higher will impose the least overhead on
* production applications.
*/
level: 'info',
},
};
+1 -1
View File
@@ -5,7 +5,7 @@ var _ = require('lodash');
var locals = require('../middlewares/api-v2/locals');
var i18n = require('../libs/api-v2/i18n');
const TOTAL_USER_COUNT = '1,000,000';
const TOTAL_USER_COUNT = '1,100,000';
// -------- App --------
router.get('/', i18n.getUserLanguage, locals, function(req, res) {