With very low CPU frequency or bad IO situation, as well as not-loaded JS CodiMD happens to present unneeded "I'm busy"-messages to users. This patch allows to configure the lag. The default is taken from the libray but set in our own default configs. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
		
			
				
	
	
		
			18 lines
		
	
	
		
			306 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			306 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict'
 | 
						|
 | 
						|
const toobusy = require('toobusy-js')
 | 
						|
 | 
						|
 | 
						|
const response = require('../../response')
 | 
						|
const config = require('../../config')
 | 
						|
 | 
						|
toobusy.maxLag(config.tooBusyLag)
 | 
						|
 | 
						|
module.exports = function (req, res, next) {
 | 
						|
  if (toobusy()) {
 | 
						|
    response.errorServiceUnavailable(res)
 | 
						|
  } else {
 | 
						|
    next()
 | 
						|
  }
 | 
						|
}
 |