mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #207 from overleaf/bg-add-exception-handler
add uncaughtException handler
This commit is contained in:
@@ -213,6 +213,12 @@ app.get('/oops', function (req, res, next) {
|
||||
return res.send('error\n')
|
||||
})
|
||||
|
||||
app.get('/oops-internal', function (req, res, next) {
|
||||
setTimeout(function () {
|
||||
throw new Error('Test error')
|
||||
}, 1)
|
||||
})
|
||||
|
||||
app.get('/status', (req, res, next) => res.send('CLSI is alive\n'))
|
||||
|
||||
Settings.processTooOld = false
|
||||
@@ -339,6 +345,15 @@ const loadHttpPort = Settings.internal.load_balancer_agent.local_port
|
||||
|
||||
if (!module.parent) {
|
||||
// Called directly
|
||||
|
||||
// handle uncaught exceptions when running in production
|
||||
if (Settings.catchErrors) {
|
||||
process.removeAllListeners('uncaughtException')
|
||||
process.on('uncaughtException', (error) =>
|
||||
logger.error({ err: error }, 'uncaughtException')
|
||||
)
|
||||
}
|
||||
|
||||
app.listen(port, host, (error) => {
|
||||
if (error) {
|
||||
logger.fatal({ error }, `Error starting CLSI on ${host}:${port}`)
|
||||
|
||||
@@ -25,6 +25,8 @@ module.exports = {
|
||||
processLifespanLimitMs:
|
||||
parseInt(process.env.PROCESS_LIFE_SPAN_LIMIT_MS) || 60 * 60 * 24 * 1000 * 2,
|
||||
|
||||
catchErrors: process.env.CATCH_ERRORS === 'true',
|
||||
|
||||
path: {
|
||||
compilesDir: Path.resolve(__dirname, '../compiles'),
|
||||
outputDir: Path.resolve(__dirname, '../output'),
|
||||
|
||||
Reference in New Issue
Block a user