mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Merged dev into master
This commit is contained in:
commit
b37e158774
1 file changed
+35
-10
@@ -137,7 +137,7 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move mods from ./sharedMods to the instances mod directory
|
// 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) {
|
//ncp("./sharedMods/", instancedirectory + "/mods", function (err) {
|
||||||
|
|
||||||
|
|
||||||
@@ -186,19 +186,42 @@ 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
|
// clean old log file to avoid crash
|
||||||
//TODO: catch '2.033 Info RemoteCommandProcessor.cpp:97: Starting RCON interface at port 35002' from stdout maybe?
|
// file exists, delete so we don't get in trouble
|
||||||
setTimeout(() => {
|
try {
|
||||||
client.connect();
|
fs.unlinkSync(instancedirectory+'/factorio-current.log')
|
||||||
}, 15000);
|
} 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 () {
|
client.on('authenticated', function () {
|
||||||
console.log('Authenticated!');
|
console.log('Clusterio | Authenticated!');
|
||||||
|
instanceManagement(); // start using rcons
|
||||||
}).on('connected', function () {
|
}).on('connected', function () {
|
||||||
console.log('Connected!');
|
console.log('Clusterio | Connected!');
|
||||||
// getID();
|
// getID();
|
||||||
}).on('disconnected', function () {
|
}).on('disconnected', function () {
|
||||||
console.log('Disconnected!');
|
console.log('Clusterio | Disconnected!');
|
||||||
// now reconnect
|
// now reconnect
|
||||||
client.connect();
|
client.connect();
|
||||||
});
|
});
|
||||||
@@ -206,7 +229,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 +274,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