mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 16:13:12 +09:00
client.js exits after creating and instance, better comments
This commit is contained in:
1 parent
7d99162072
commit
d177fb7304
1 file changed
+9
-11
@@ -310,6 +310,7 @@ write-data=__PATH__executable__/../../../"+config.instanceDirectory+"/" + instan
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
console.log("Instance created!");
|
console.log("Instance created!");
|
||||||
|
process.exit(0);
|
||||||
} else if (command == "start" && typeof instance == "string" && instance != "/" && fs.existsSync(instancedirectory)) {
|
} else if (command == "start" && typeof instance == "string" && instance != "/" && fs.existsSync(instancedirectory)) {
|
||||||
// Exit if no instance specified (it should be, just a safeguard);
|
// Exit if no instance specified (it should be, just a safeguard);
|
||||||
if(instancedirectory != config.instanceDirectory+"/undefined"){
|
if(instancedirectory != config.instanceDirectory+"/undefined"){
|
||||||
@@ -345,9 +346,7 @@ write-data=__PATH__executable__/../../../"+config.instanceDirectory+"/" + instan
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move mods from ./sharedMods to the instances mod directory
|
// move mods from ./sharedMods to the instances mod directory
|
||||||
try {
|
try{fs.mkdirSync(instancedirectory + "/instanceMods/");}catch(e){}
|
||||||
fs.mkdirSync(instancedirectory + "/instanceMods/");
|
|
||||||
} catch(e){}
|
|
||||||
try{rmdirSync(instancedirectory + "/mods");}catch(e){}
|
try{rmdirSync(instancedirectory + "/mods");}catch(e){}
|
||||||
try {
|
try {
|
||||||
// mods directory that will be emptied (deleted) when closing the server to facilitate seperation of instanceMods and sharedMods
|
// mods directory that will be emptied (deleted) when closing the server to facilitate seperation of instanceMods and sharedMods
|
||||||
@@ -359,7 +358,7 @@ write-data=__PATH__executable__/../../../"+config.instanceDirectory+"/" + instan
|
|||||||
fs.copySync(instancedirectory + "/instanceMods", instancedirectory + "/mods");
|
fs.copySync(instancedirectory + "/instanceMods", instancedirectory + "/mods");
|
||||||
|
|
||||||
process.on('SIGINT', function () {
|
process.on('SIGINT', function () {
|
||||||
console.log("Caught interrupt signal");
|
console.log("Caught interrupt signal, sending /quit");
|
||||||
messageInterface("/quit");
|
messageInterface("/quit");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -367,8 +366,9 @@ write-data=__PATH__executable__/../../../"+config.instanceDirectory+"/" + instan
|
|||||||
//var serverprocess = child_process.exec(commandline);
|
//var serverprocess = child_process.exec(commandline);
|
||||||
fileOps.getNewestFile(instancedirectory + "/saves/", fs.readdirSync(instancedirectory + "/saves/"),function(err, latestSave) {
|
fileOps.getNewestFile(instancedirectory + "/saves/", fs.readdirSync(instancedirectory + "/saves/"),function(err, latestSave) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log("Your savefile seems to be missing. This might because you created an instance without having factorio\
|
console.error("ERROR!")
|
||||||
installed and configured properly. Try installing factorio and adding your savefile to instances/[instancename]/saves/");
|
console.error("Your savefile seems to be missing. This might because you created an instance without having factorio\
|
||||||
|
installed and configured properly. Try installing factorio and adding your savefile to instances/[instancename]/saves/\n");
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
// implicit global
|
// implicit global
|
||||||
@@ -397,10 +397,8 @@ write-data=__PATH__executable__/../../../"+config.instanceDirectory+"/" + instan
|
|||||||
client.close();
|
client.close();
|
||||||
client.connect();
|
client.connect();
|
||||||
}
|
}
|
||||||
if(process.platform == "linux"){
|
// we have to do this to make logs visible on linux and in powershell. Causes log duplication for people with CMD.
|
||||||
// we have to log on linux because linux only shows stdout of the first process launched
|
console.log('Fact: ' + data);
|
||||||
console.log('Factorio: ' + data);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
serverprocess.stderr.on('data', (chunk) => {
|
serverprocess.stderr.on('data', (chunk) => {
|
||||||
console.log('ERR: ' + chunk);
|
console.log('ERR: ' + chunk);
|
||||||
@@ -445,7 +443,7 @@ write-data=__PATH__executable__/../../../"+config.instanceDirectory+"/" + instan
|
|||||||
process.exit(0); // exit because RCON disconnecting is undefined behaviour and we rather just wanna restart now
|
process.exit(0); // exit because RCON disconnecting is undefined behaviour and we rather just wanna restart now
|
||||||
});
|
});
|
||||||
} else if(process.platform == "linux"){
|
} else if(process.platform == "linux"){
|
||||||
// TODO: Check if this works fine on linux or if it has to be delayed until the server starts properly
|
// don't open an RCON connection and just use stdio instead, does not work on windows.
|
||||||
instanceManagement();
|
instanceManagement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user