mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-17 06:13:11 +01:00
Merge pull request #532 from torarnv/handle-shutdown-signals
Handle SIGINT and SIGTERM to enable clean shutdown of Homebridge
This commit is contained in:
14
lib/cli.js
14
lib/cli.js
@@ -23,5 +23,17 @@ module.exports = function() {
|
|||||||
// Initialize HAP-NodeJS with a custom persist directory
|
// Initialize HAP-NodeJS with a custom persist directory
|
||||||
hap.init(User.persistPath());
|
hap.init(User.persistPath());
|
||||||
|
|
||||||
new Server(insecureAccess).run();
|
var server = new Server(insecureAccess);
|
||||||
|
|
||||||
|
var signals = { 'SIGINT': 2, 'SIGTERM': 15 };
|
||||||
|
Object.keys(signals).forEach(function (signal) {
|
||||||
|
process.on(signal, function () {
|
||||||
|
log.info("Got %s, shutting down Homebridge...", signal);
|
||||||
|
|
||||||
|
// FIXME: Shut down server cleanly
|
||||||
|
process.exit(128 + signals[signal]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
server.run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user