mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Replace device:support:quit with util:lifecycle, which is usable by non-device processes too.
This commit is contained in:
parent
e17f306d30
commit
d6604bcda8
11 changed files with 75 additions and 179 deletions
|
@ -5,10 +5,10 @@ var logger = require('../util/logger')
|
|||
var wire = require('../wire')
|
||||
var wireutil = require('../wire/util')
|
||||
var dbapi = require('../db/api')
|
||||
var lifecycle = require('../util/lifecycle')
|
||||
|
||||
module.exports = function(options) {
|
||||
var log = logger.createLogger('reaper')
|
||||
, quit = Promise.defer()
|
||||
, timer
|
||||
|
||||
if (options.name) {
|
||||
|
@ -40,28 +40,10 @@ module.exports = function(options) {
|
|||
})
|
||||
.catch(function(err) {
|
||||
log.error('Failed to load device list: ', err.message, err.stack)
|
||||
quit.reject(err)
|
||||
lifecycle.fatal()
|
||||
})
|
||||
}
|
||||
|
||||
timer = setInterval(reap, options.reapInterval)
|
||||
|
||||
process.on('SIGINT', function() {
|
||||
quit.resolve()
|
||||
})
|
||||
|
||||
process.on('SIGTERM', function() {
|
||||
quit.resolve()
|
||||
})
|
||||
|
||||
quit.promise
|
||||
.then(function() {
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.fatal('Error caused quit: ', err.stack)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
log.info('Reaping devices with no heartbeat')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue