You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
517 B
18 lines
517 B
/**
|
|
* Stopper middleware is responsible for communicating with `karma stop`.
|
|
*/
|
|
|
|
const log = require('../logger').create('middleware:stopper')
|
|
|
|
function createStopperMiddleware (urlRoot) {
|
|
return function (request, response, next) {
|
|
if (request.url !== urlRoot + 'stop') return next()
|
|
response.writeHead(200)
|
|
log.info('Stopping server')
|
|
response.end('OK')
|
|
process.kill(process.pid, 'SIGINT')
|
|
}
|
|
}
|
|
|
|
createStopperMiddleware.$inject = ['config.urlRoot']
|
|
exports.create = createStopperMiddleware
|