mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Fix crash on slow startup, resolves #40
This commit is contained in:
1 parent
e610d23525
commit
4f1cfce39c
1 file changed
+20
-7
@@ -186,14 +186,25 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
|||||||
timeout: 0
|
timeout: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
// wait a few seconds to let the server finish starting before connecting rcon
|
// check the logfile to see if the RCON interface is running as there is no way to continue without it
|
||||||
//TODO: catch '2.033 Info RemoteCommandProcessor.cpp:97: Starting RCON interface at port 35002' from stdout maybe?
|
// we read the log every 2 seconds and stop looping when we start connecting to factorio
|
||||||
setTimeout(() => {
|
function checkRcon() {
|
||||||
client.connect();
|
fs.readFile(instancedirectory+"/factorio-current.log", function (err, data) {
|
||||||
}, 15000);
|
if (err) throw err;
|
||||||
|
if(data.indexOf('Starting RCON interface') > 0){
|
||||||
|
client.connect();
|
||||||
|
} else {
|
||||||
|
setTimeout(function(){
|
||||||
|
checkRcon();
|
||||||
|
},2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
checkRcon();
|
||||||
|
|
||||||
client.on('authenticated', function () {
|
client.on('authenticated', function () {
|
||||||
console.log('Authenticated!');
|
console.log('Authenticated!');
|
||||||
|
instanceManagement(); // start using rcons
|
||||||
}).on('connected', function () {
|
}).on('connected', function () {
|
||||||
console.log('Connected!');
|
console.log('Connected!');
|
||||||
// getID();
|
// getID();
|
||||||
@@ -206,7 +217,9 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
|||||||
// set some globals
|
// set some globals
|
||||||
confirmedOrders = [];
|
confirmedOrders = [];
|
||||||
lastSignalCheck = Date.now();
|
lastSignalCheck = Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
function instanceManagement() {
|
||||||
// world IDs ------------------------------------------------------------------
|
// world IDs ------------------------------------------------------------------
|
||||||
hashMods(instance, function(modHashes){
|
hashMods(instance, function(modHashes){
|
||||||
setInterval(getID, 10000);
|
setInterval(getID, 10000);
|
||||||
@@ -249,7 +262,7 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
|||||||
hash: modHashes[i].hash,
|
hash: modHashes[i].hash,
|
||||||
}
|
}
|
||||||
needle.post(config.masterIP + ":" + config.masterPort + '/checkMod', payload, function (err, response, body) {
|
needle.post(config.masterIP + ":" + config.masterPort + '/checkMod', payload, function (err, response, body) {
|
||||||
if(err) throw err
|
if(err) throw err // Unable to contact master server! Please check your config.json.
|
||||||
if(response && body && body == "found") {
|
if(response && body && body == "found") {
|
||||||
console.log("master has mod")
|
console.log("master has mod")
|
||||||
} else if (response && body && typeof body == "string") {
|
} else if (response && body && typeof body == "string") {
|
||||||
|
|||||||
Reference in new issue
Block a user