Skip to content

Commit

Permalink
Quit zigbee-shepherd friendly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Apr 8, 2018
1 parent 3f37c43 commit bc40911
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ shepherd.on('ready', handleReady);
shepherd.on('permitJoining', handlePermitJoining);
client.on('connect', handleConnect);
shepherd.on('ind', handleInd);
process.on('SIGINT', handleQuit);

// Start server
console.log(`Starting zigbee-shepherd with device ${args.device}`)
Expand Down Expand Up @@ -150,4 +151,17 @@ function handleInd(msg) {
console.log("MQTT Reporting to ", topic, " value ", pl)
client.publish(topic, pl.toString());
}
}
}

function handleQuit() {
console.log("Stopping zigbee-shepherd...");
shepherd.stop((err) => {
if (err) {
console.error('Error while stopping zigbee-shepherd');
} else {
console.error('zigbee-shepherd stopped')
}

process.exit();
});
}

0 comments on commit bc40911

Please sign in to comment.