cleanup the shutdown code a bit
This commit is contained in:
19
app.js
19
app.js
@@ -207,17 +207,16 @@ const resCacher = {
|
|||||||
setContentType: 'application/json'
|
setContentType: 'application/json'
|
||||||
}
|
}
|
||||||
|
|
||||||
const startupTime = Date.now()
|
let shutdownTime
|
||||||
|
if (Settings.processLifespanLimitMs) {
|
||||||
|
Settings.processLifespanLimitMs +=
|
||||||
|
Settings.processLifespanLimitMs * (Math.random() / 10)
|
||||||
|
shutdownTime = Date.now() + Settings.processLifespanLimitMs
|
||||||
|
logger.info('Lifespan limited to ', shutdownTime)
|
||||||
|
}
|
||||||
|
|
||||||
const checkIfProcessIsTooOld = function(cont) {
|
const checkIfProcessIsTooOld = function(cont) {
|
||||||
if (typeof Settings.processLifespanLimitMs === 'string') {
|
if (shutdownTime && shutdownTime < Date.now()) {
|
||||||
Settings.processLifespanLimitMs = parseInt(Settings.processLifespanLimitMs)
|
|
||||||
Settings.processLifespanLimitMs +=
|
|
||||||
Settings.processLifespanLimitMs * (Math.random() / 10)
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
Settings.processLifespanLimitMs &&
|
|
||||||
startupTime + Settings.processLifespanLimitMs < Date.now()
|
|
||||||
) {
|
|
||||||
logger.log('shutting down, process is too old')
|
logger.log('shutting down, process is too old')
|
||||||
resCacher.send = function() {}
|
resCacher.send = function() {}
|
||||||
resCacher.code = 500
|
resCacher.code = 500
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ module.exports = {
|
|||||||
compileSizeLimit: process.env.COMPILE_SIZE_LIMIT || '7mb',
|
compileSizeLimit: process.env.COMPILE_SIZE_LIMIT || '7mb',
|
||||||
|
|
||||||
processLifespanLimitMs:
|
processLifespanLimitMs:
|
||||||
process.env.PROCESS_LIFE_SPAN_LIMIT_MS || 60 * 60 * 24 * 1000 * 2,
|
parseInt(process.env.PROCESS_LIFE_SPAN_LIMIT_MS) || 60 * 60 * 24 * 1000 * 2,
|
||||||
|
|
||||||
path: {
|
path: {
|
||||||
compilesDir: Path.resolve(__dirname + '/../compiles'),
|
compilesDir: Path.resolve(__dirname + '/../compiles'),
|
||||||
|
|||||||
Reference in New Issue
Block a user