mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Check mpd really is listening on port 6600 before allowing nodes to exist.
Otherwise komponist fails badly.
This commit is contained in:
parent
03484169e3
commit
ea74eebff2
@ -15,8 +15,10 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
||||||
|
var util = require("util");
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
var komponist = require('komponist');
|
var komponist = require('komponist');
|
||||||
|
var mpc = "";
|
||||||
exec("which mpd",function(err,stdout,stderr) {
|
exec("which mpd",function(err,stdout,stderr) {
|
||||||
if (stdout.indexOf('mpd') == -1) {
|
if (stdout.indexOf('mpd') == -1) {
|
||||||
util.log('[69-mpd.js] Error: Cannot find "mpd" command. Please install MPD.');
|
util.log('[69-mpd.js] Error: Cannot find "mpd" command. Please install MPD.');
|
||||||
@ -24,7 +26,11 @@ exec("which mpd",function(err,stdout,stderr) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var mpc = "";
|
exec("netstat -an | grep LISTEN | grep 6600",function(err,stdout,stderr) {
|
||||||
|
if (stdout.indexOf('6600') == -1) {
|
||||||
|
util.log('[69-mpd.js] Error: MPD daemon not listening on port 6600. Please start MPD.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
komponist.createConnection(6600, 'localhost', function(err, client) {
|
komponist.createConnection(6600, 'localhost', function(err, client) {
|
||||||
if (err) node.error("MPD: Failed to connect to MPD server");
|
if (err) node.error("MPD: Failed to connect to MPD server");
|
||||||
mpc = client;
|
mpc = client;
|
||||||
@ -89,3 +95,5 @@ function MPDIn(n) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("mpd in",MPDIn);
|
RED.nodes.registerType("mpd in",MPDIn);
|
||||||
|
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user