zigbee2mqtt/index.js
Willi Eggeling 69d04d0648 shutdown controller on SIGTERM (#1313)
Previously, the controller was only properly shutdown on SIGINT.
SIGTERM is used by kill (unix) and to stop Docker containers.
2019-03-24 14:27:49 +01:00

19 lines
546 B
JavaScript

const semver = require('semver');
const engines = require('./package.json').engines;
const version = engines.node;
if (!semver.satisfies(process.version, version)) {
console.log(`\t\tZigbee2mqtt requires node version ${version}, you are running ${process.version}!\n`); // eslint-disable-line
}
const Controller = require('./lib/controller');
const controller = new Controller();
controller.start();
process.on('SIGINT', handleQuit);
process.on('SIGTERM', handleQuit);
function handleQuit() {
controller.stop(() => process.exit());
}