mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-20 03:53:39 +02:00
Replace device:support:quit with util:lifecycle, which is usable by non-device processes too.
This commit is contained in:
@@ -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')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user