Tried to fix occasional crash when saving related to getMac

This commit is contained in:
Danielv123 committed 2017-09-16 16:47:16 +02:00
1 parent 08143b7b84
commit 8742e34d9f
1 file changed
+17 -13
+17 -13
View File
@@ -420,20 +420,24 @@ function instanceManagement() {
playerCount: instanceInfo.playerCount || 0, playerCount: instanceInfo.playerCount || 0,
instanceName: instance, instanceName: instance,
} }
require('getmac').getMac(function (err, mac) { try {
if (err) throw err require('getmac').getMac(function (err, mac) {
payload.mac = mac if (err) throw err
console.log("Registered our precense with master "+config.masterIP+" at " + payload.time); payload.mac = mac
needle.post(config.masterIP + ":" + config.masterPort + '/api/getID', payload, function (err, response, body) { console.log("Registered our precense with master "+config.masterIP+" at " + payload.time);
if (err && err.code != "ECONNRESET"){ needle.post(config.masterIP + ":" + config.masterPort + '/api/getID', payload, function (err, response, body) {
console.error("We got problems, something went wrong when contacting master"); if (err && err.code != "ECONNRESET"){
console.error(err); console.error("We got problems, something went wrong when contacting master");
} else if (response && response.body) { console.error(err);
// In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care. } else if (response && response.body) {
console.log(response.body); // In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care.
} console.log(response.body);
}
});
}); });
}); } catch (e){
console.log("##### getMac crashed, but we don't really give a shit because we are probably closing down #####");
}
},1000)}); },1000)});
} }
}); });