forked from jeresig/i18n-node-2
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi,
I moved from i18l-2 to loc as I like the featureset
I got everything working for me locally and it was fine.
I deployed the website onto my server (Fedora 23, Node 4 LTS from NodeSource)
I found that it would run for a maximum of around 1 minute and then hang, refusing requests
Node CPU usage would hit 100% and it would stay that way until the process was killed.
I’m not sure what useful information I could give you to help track down this bug, indeed I only worked out it was loc causing the problem by going through my app.js and turning off features one at a time until the website stayed up.
My app.js is:
/* eslint-disable no-console */
'use strict';
const bodyParser = require('body-parser'),
config = require('./app/config'),
env = process.env.NODE_ENV || 'development',
errorHandler = require('errorhandler'),
express = require('express'),
expressHandlebars = require('express-handlebars'),
http = require('http'),
loc = require('loc'),
methodOverride = require('method-override'),
minifyHTML = require('express-minify-html'),
morgan = require('morgan'),
myConnection = require('express-myconnection'), // express-myconnection module
mysql = require('mysql'), // node-mysql module
path = require('path'),
routes = require('./app/routes/router');
var app = express();
app.version = '0.1.srs3142';
var versionator = require('versionator').create(app.version);
app.set('port', process.env.PORT || 5555);
app.enable('trust proxy');
//app.set('view engine', 'ejs');
app.disable('x-powered-by');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(myConnection(mysql, config.db, 'pool'));
app.use(versionator.middleware);
loc({
getLocaleFrom: ['path', 'query', 'subdomain', 'cookie'],
storeLocaleTo: ['cookie'],
storage: 'file',
locales: ['de', 'en', 'en-GB', 'en-us'],
directory: './app/locales',
defaultLocale: 'en',
extension: '.json',
excludeList: ['.css', '.js', '.ico', '/api/', '/images/', '/css/', '/js/', '/p/']
}).bind(app);
app.locals = {
version: app.version,
versionPath: versionator.versionPath
};
app.use(function (req, res, next) {
app.locals.locale = req.i18n.getLocale();
next();
});
app.set('views', __dirname + '/app/views');
app.engine('.hbs', expressHandlebars({
extname: '.hbs',
defaultLayout: 'default',
layoutsDir: 'app/views/layouts',
partialsDir: 'app/views/partials'
}));
if (env === 'development') {
app.use(errorHandler());
app.use(morgan('dev'));
app.use(express.static(path.join(__dirname, '/app/public/')));
app.use(function(req, res, next) {
if (req.accepts('html')) {
res.setHeader('Pragma', 'no-cache');
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
res.setHeader('Expires', '0');
}
return next();
});
} else {
app.use(errorHandler());
app.use(morgan('combined'));
app.set('trust proxy', 1);
app.set('x-powered-by', false);
app.use(express.static(path.join(__dirname, '/app/public/'), { maxAge: 2592000000 }));
app.use(minifyHTML({
override: true,
displayErrors: true,
htmlMinifier: {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
minifyJS: true
}
}));
}
app.use(function (req, res, next) {
if (req.url === '/robots.txt') {
res.type('text/plain');
res.send(
`User-agent: *
Disallow: /en-GB/checkout
Disallow: /en-gb/checkout
Disallow: /en-us/checkout
Disallow: /en-US/checkout
Disallow: /en/checkout
Disallow: /de/checkout
Disallow: /checkout
Disallow: /en-GB/order
Disallow: /en-gb/order
Disallow: /en-us/order
Disallow: /en-US/order
Disallow: /en/order
Disallow: /de/order
Disallow: /order
`
);
} else {
next();
}
});
app.set('view engine', '.hbs');
app.use('/', routes);
http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});
module.exports = app;
and my routes are:
router.get('/', index);
router.get('/More', index);
router.get('/Shop', shop);
router.get('/shop', shop);
router.get('/:gal', gallery);
router.get('/:gal/json', gallery);
router.get('/shop/p/:farm/:server/:key/:extra', shopitem);
router.get('/Shop/p/:farm/:server/:key/:extra', shopitem);
router.get('/:path/p/:farm/:server/:key/:extra', picview);
router.post('/checkout', checkout);
router.post('/order', order);
router.post('/buy', fin);
If there’s anything else you need, let me know? Or anything you want me to try?
Metadata
Metadata
Assignees
Labels
No labels