mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-15 01:55:29 +00:00
start drain after 3 hours
This commit is contained in:
parent
9a851d6cce
commit
7f2decae4d
4 changed files with 29 additions and 18 deletions
|
@ -19,6 +19,8 @@ Metrics.initialize(Settings.appName or "real-time")
|
|||
Metrics.event_loop.monitor(logger)
|
||||
|
||||
|
||||
DrainManager = require("./app/js/DrainManager")
|
||||
|
||||
# Set up socket.io server
|
||||
app = express()
|
||||
server = require('http').createServer(app)
|
||||
|
@ -81,17 +83,28 @@ Error.stackTraceLimit = 10
|
|||
|
||||
|
||||
shutdownCleanly = (signal) ->
|
||||
return () ->
|
||||
logger.log signal: signal, "received interrupt, cleaning up"
|
||||
connectedClients = io.sockets.clients()?.length
|
||||
logger.log {connectedClients, signal}, "looking to shut down process"
|
||||
if connectedClients == 0
|
||||
logger.log("no clients connected, exiting")
|
||||
process.exit()
|
||||
else
|
||||
setTimeout () ->
|
||||
shutdownCleanly(signal)
|
||||
, 10000
|
||||
connectedClients = io.sockets.clients()?.length
|
||||
logger.log {connectedClients, signal}, "looking to shut down process"
|
||||
if connectedClients == 0
|
||||
logger.log("no clients connected, exiting")
|
||||
process.exit()
|
||||
else
|
||||
setTimeout () ->
|
||||
shutdownCleanly(signal)
|
||||
, 10000
|
||||
|
||||
for signal in ['SIGINT', 'SIGHUP', 'SIGQUIT', 'SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGABRT']
|
||||
process.on signal, shutdownCleanly(signal)
|
||||
forceDrain = ->
|
||||
THREE_HOURS = 60 * 1000 * 60 * 3
|
||||
setTimeout( -> ,
|
||||
logger.log({delay_ms:THREE_HOURS}, "starting drain")
|
||||
DrainManager.startDrain(io, 4)
|
||||
, THREE_HOURS)
|
||||
|
||||
|
||||
if Settings.drainBeforeShutdown
|
||||
logger.log "drainBeforeShutdown enabled"
|
||||
for signal in ['SIGINT', 'SIGHUP', 'SIGQUIT', 'SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGABRT']
|
||||
logger.log signal: signal, "received interrupt, cleaning up"
|
||||
process.on signal, ->
|
||||
shutdownCleanly(signal)
|
||||
forceDrain()
|
||||
|
|
|
@ -5,8 +5,6 @@ redis = require("redis-sharelatex")
|
|||
rclient = redis.createClient(Settings.redis.realtime)
|
||||
Keys = Settings.redis.realtime.key_schema
|
||||
|
||||
console.log Settings.redis.realtime, "REALTIME"
|
||||
|
||||
ONE_HOUR_IN_S = 60 * 60
|
||||
ONE_DAY_IN_S = ONE_HOUR_IN_S * 24
|
||||
FOUR_DAYS_IN_S = ONE_DAY_IN_S * 4
|
||||
|
|
|
@ -4,8 +4,6 @@ redis = require("redis-sharelatex")
|
|||
rclient = redis.createClient(settings.redis.documentupdater)
|
||||
SafeJsonParse = require "./SafeJsonParse"
|
||||
|
||||
console.log "REDIS", settings.redis
|
||||
|
||||
MESSAGE_SIZE_LOG_LIMIT = 1024 * 1024 # 1Mb
|
||||
|
||||
module.exports = DocumentUpdaterController =
|
||||
|
|
|
@ -40,4 +40,6 @@ module.exports =
|
|||
|
||||
cookieName: process.env['COOKIE_NAME'] or "sharelatex.sid"
|
||||
|
||||
max_doc_length: 2 * 1024 * 1024 # 2mb
|
||||
max_doc_length: 2 * 1024 * 1024 # 2mb
|
||||
|
||||
drainBeforeShutdown: process.env['DRAIN_BEFORE_SHUTDOWN'] or false
|
Loading…
Add table
Reference in a new issue