5 Commits

Author SHA1 Message Date
Khaos Tian
6500912f54 0.2.19 2016-02-22 16:50:52 -08:00
Khaos Tian
2e2c8eb207 Update hap-nodejs dependency for iOS 9.3 2016-02-22 16:50:33 -08:00
Khaos Tian
0b28387cb1 Merge pull request #532 from torarnv/handle-shutdown-signals
Handle SIGINT and SIGTERM to enable clean shutdown of Homebridge
2016-02-18 14:47:41 -08:00
Tor Arne Vestbø
cf80e4f2da Handle SIGINT and SIGTERM to enable clean shutdown of Homebridge
For now we terminate the process, but in the future we may tell the
server to stop, which may possibly include some teardown logic.

Handling these signals also make it easier to put Homebridge inside
a docker container, as docker uses SIGTERM to tell a container process
to stop, and passes SIGINT when attached to the container and receiving
a Ctrl+C.
2016-02-18 00:36:56 +01:00
Nick Farina
57beabf0b4 Add comment 2016-02-17 10:43:54 -08:00
3 changed files with 21 additions and 4 deletions

View File

@@ -17,11 +17,23 @@ module.exports = function() {
.option('-P, --plugin-path [path]', 'look for plugins installed at [path] as well as the default locations ([path] can also point to a single plugin)', function(p) { Plugin.addPluginPath(p); })
.option('-U, --user-storage-path [path]', 'look for homebridge user files at [path] instead of the default location (~/.homebridge)', function(p) { User.setStoragePath(p); })
.option('-D, --debug', 'turn on debug level logging', function() { require('./logger').setDebugEnabled(true) })
.option('-I, --insecure', 'allow insecure access to homebridge', function() { insecureAccess = true; })
.option('-I, --insecure', 'allow unauthenticated requests (for easier hacking)', function() { insecureAccess = true })
.parse(process.argv);
// Initialize HAP-NodeJS with a custom persist directory
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();
}

View File

@@ -25,6 +25,11 @@ function Server(insecureAccess) {
this._config = this._loadConfig();
this._bridge = this._createBridge();
// Server is "secure by default", meaning it creates a top-level Bridge accessory that
// will not allow unauthenticated requests. This matches the behavior of actual HomeKit
// accessories. However you can set this to true to allow all requests without authentication,
// which can be useful for easy hacking. Note that this will expose all functions of your
// bridged accessories, like changing charactersitics (i.e. flipping your lights on and off).
this._allowInsecureAccess = insecureAccess || false;
}

View File

@@ -1,7 +1,7 @@
{
"name": "homebridge",
"description": "HomeKit support for the impatient",
"version": "0.2.18",
"version": "0.2.19",
"scripts": {
"dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true"
},
@@ -31,7 +31,7 @@
"dependencies": {
"chalk": "^1.1.1",
"commander": "2.8.1",
"hap-nodejs": "0.2.3",
"hap-nodejs": "0.2.5",
"semver": "5.0.3"
}
}