mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Merged dev into master
This commit is contained in:
commit
b37e158774
1 file changed
+36
-11
@@ -137,7 +137,7 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
||||
}
|
||||
|
||||
// move mods from ./sharedMods to the instances mod directory
|
||||
console.log("Moving shared mods...")
|
||||
console.log("Clusterio | Moving shared mods...")
|
||||
//ncp("./sharedMods/", instancedirectory + "/mods", function (err) {
|
||||
|
||||
|
||||
@@ -186,19 +186,42 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
||||
timeout: 0
|
||||
});
|
||||
|
||||
// wait a few seconds to let the server finish starting before connecting rcon
|
||||
//TODO: catch '2.033 Info RemoteCommandProcessor.cpp:97: Starting RCON interface at port 35002' from stdout maybe?
|
||||
setTimeout(() => {
|
||||
client.connect();
|
||||
}, 15000);
|
||||
|
||||
// clean old log file to avoid crash
|
||||
// file exists, delete so we don't get in trouble
|
||||
try {
|
||||
fs.unlinkSync(instancedirectory+'/factorio-current.log')
|
||||
} catch (err){
|
||||
if(err){
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log("Clusterio | Deleting old logs...")
|
||||
}
|
||||
}
|
||||
|
||||
// check the logfile to see if the RCON interface is running as there is no way to continue without it
|
||||
// we read the log every 2 seconds and stop looping when we start connecting to factorio
|
||||
function checkRcon() {
|
||||
fs.readFile(instancedirectory+"/factorio-current.log", function (err, data) {
|
||||
// if (err) console.log(err);
|
||||
if(data && data.indexOf('Starting RCON interface') > 0){
|
||||
client.connect();
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
checkRcon();
|
||||
},2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
checkRcon();
|
||||
|
||||
client.on('authenticated', function () {
|
||||
console.log('Authenticated!');
|
||||
console.log('Clusterio | Authenticated!');
|
||||
instanceManagement(); // start using rcons
|
||||
}).on('connected', function () {
|
||||
console.log('Connected!');
|
||||
console.log('Clusterio | Connected!');
|
||||
// getID();
|
||||
}).on('disconnected', function () {
|
||||
console.log('Disconnected!');
|
||||
console.log('Clusterio | Disconnected!');
|
||||
// now reconnect
|
||||
client.connect();
|
||||
});
|
||||
@@ -206,7 +229,9 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
||||
// set some globals
|
||||
confirmedOrders = [];
|
||||
lastSignalCheck = Date.now();
|
||||
}
|
||||
|
||||
function instanceManagement() {
|
||||
// world IDs ------------------------------------------------------------------
|
||||
hashMods(instance, function(modHashes){
|
||||
setInterval(getID, 10000);
|
||||
@@ -249,7 +274,7 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
||||
hash: modHashes[i].hash,
|
||||
}
|
||||
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") {
|
||||
console.log("master has mod")
|
||||
} else if (response && body && typeof body == "string") {
|
||||
|
||||
Reference in new issue
Block a user