mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 23:14:53 +09:00
Housekeeping, more config settings
This commit is contained in:
1 parent
234e6eba4c
commit
2234d41655
4 files changed
+55
-45
No files matched your search
@@ -6,6 +6,10 @@ var child_process = require('child_process');
|
||||
var config = require('./config');
|
||||
|
||||
var instance = process.argv[2];
|
||||
if(!instance){
|
||||
console.error("Usage: node client.js [instance name]")
|
||||
process.exit(1)
|
||||
}
|
||||
var instancedirectory = './instances/'+instance;
|
||||
if (!fs.existsSync(instancedirectory)){
|
||||
fs.mkdirSync(instancedirectory);
|
||||
@@ -20,39 +24,39 @@ read-data=__PATH__executable__\\..\\..\\data\r\n\
|
||||
write-data=__PATH__executable__\\..\\..\\..\\instances\\"+instance+"\r\n\
|
||||
");
|
||||
|
||||
var instconf = {
|
||||
"factorioPort": "35001",
|
||||
"clientPort": "35002",
|
||||
"clientPassword": "clusterio"
|
||||
}
|
||||
fs.writeFileSync(instancedirectory + "/config.json", JSON.stringify(instconf, null, 4));
|
||||
var instconf = {
|
||||
"factorioPort": "35001",
|
||||
"clientPort": "35002",
|
||||
"clientPassword": "clusterio"
|
||||
}
|
||||
fs.writeFileSync(instancedirectory + "/config.json", JSON.stringify(instconf, null, 4));
|
||||
|
||||
var serversettings = {
|
||||
"name": config.username +"'s clusterio "+instance,
|
||||
"description": "",
|
||||
"tags": ["clusterio"],
|
||||
"max_players": "20",
|
||||
"visibility": "lan",
|
||||
"username": config.username,
|
||||
"token": config.usertoken,
|
||||
"game_password": "",
|
||||
"verify_user_identity": true,
|
||||
"admins":[config.username],
|
||||
"allow_commands":"admins-only",
|
||||
"autosave_interval":10,
|
||||
"autosave_slots":5,
|
||||
"afk_autokick_interval":0,
|
||||
"auto_pause":false
|
||||
}
|
||||
fs.writeFileSync(instancedirectory + "/server-settings.json", JSON.stringify(serversettings, null, 4));
|
||||
var serversettings = {
|
||||
"name": config.username +"'s clusterio "+instance,
|
||||
"description": config.description,
|
||||
"tags": ["clusterio"],
|
||||
"max_players": "20",
|
||||
"visibility": "lan",
|
||||
"username": config.username,
|
||||
"token": config.usertoken,
|
||||
"game_password": config.game_password,
|
||||
"verify_user_identity": config.verify_user_identity,
|
||||
"admins":[config.username],
|
||||
"allow_commands":config.allow_commands,
|
||||
"autosave_interval":10,
|
||||
"autosave_slots":5,
|
||||
"afk_autokick_interval":0,
|
||||
"auto_pause":config.auto_pause
|
||||
}
|
||||
fs.writeFileSync(instancedirectory + "/server-settings.json", JSON.stringify(serversettings, null, 4));
|
||||
|
||||
var createSave = child_process.spawnSync(
|
||||
'./factorio/bin/x64/factorio.exe',
|
||||
[
|
||||
'-c',instancedirectory+'/config.ini',
|
||||
'--create',instancedirectory+'/save.zip',
|
||||
]
|
||||
)
|
||||
var createSave = child_process.spawnSync(
|
||||
'./' + config.factorioDirectory + '/bin/x64/factorio.exe',
|
||||
[
|
||||
'-c',instancedirectory+'/config.ini',
|
||||
'--create',instancedirectory+'/save.zip',
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
var instanceconfig = require(instancedirectory+'/config');
|
||||
@@ -66,7 +70,7 @@ process.on('SIGINT', function() {
|
||||
|
||||
//var serverprocess = child_process.exec(commandline)
|
||||
var serverprocess = child_process.spawn(
|
||||
'./factorio/bin/x64/factorio.exe',
|
||||
'./' + config.factorioDirectory + '/bin/x64/factorio.exe',
|
||||
[
|
||||
'-c',instancedirectory+'/config.ini',
|
||||
'--start-server',instancedirectory+'/save.zip',
|
||||
@@ -221,7 +225,8 @@ setInterval(function() {
|
||||
});
|
||||
// after fetching all the latest frames, we take a timestamp. During the next iteration, we fetch all frames submitted after this.
|
||||
lastSignalCheck = Date.now();
|
||||
|
||||
|
||||
// get outbound frames from file and send to master
|
||||
// get array of lines in file, each line should correspond to a JSON encoded frame
|
||||
signals = fs.readFileSync(instancedirectory + "/script-output/txbuffer.txt", "utf8").split("\n");
|
||||
// if we actually got anything from the file, proceed and reset file
|
||||
|
||||
+15
-4
@@ -1,8 +1,19 @@
|
||||
{
|
||||
"__comment": "IP and port for the clusterio master",
|
||||
"__comment": "Where factorio folder. Should be in the same folder as this config file.",
|
||||
"factorioDirectory": "factorio_0.14.9
|
||||
|
||||
"__comment": "IP the master web server runs at, can be ignored on the master system",
|
||||
"masterIP": "localhost",
|
||||
"masterPort": 8080,
|
||||
"__comment": "credentials for factorio MP services",
|
||||
"username": "",
|
||||
"usertoken": ""
|
||||
|
||||
"__comment": "credentials for factorio MP services",
|
||||
"username": "",
|
||||
"usertoken": "",
|
||||
|
||||
"__comment": "General user settings",
|
||||
"verify_user_identity": true,
|
||||
"auto_pause": false,
|
||||
"allow_commands": "admins-only",
|
||||
"game_password": "",
|
||||
"description": "This server runs Clusterio",
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.15.2",
|
||||
"child_process": "^1.0.2",
|
||||
"express": "^4.14.0",
|
||||
"fs": "0.0.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
|
||||
+1
-8
@@ -183,14 +183,8 @@ setInterval(function() {
|
||||
}, 500)
|
||||
|
||||
// image data
|
||||
// key is the name of the item in the database, value is the name of the image on wiki.factorio.com/images/*
|
||||
var imagedata = {
|
||||
["raw-wood"]: "Raw-wood",
|
||||
["alien-artifact"]: "Alien-artifact",
|
||||
["heavy-oil"]: "Heavy-oil",
|
||||
["engine-unit"]: "Engine-unit",
|
||||
["electric-engine-unit"]: "Electric-engine-unit",
|
||||
["flying-robot-frame"]: "Flying-robot-frame",
|
||||
["alien-science_pack"]: "Alien-science-pack",
|
||||
["empty-barrel"]: "Barrel-empty",
|
||||
["transport-belt"]: "Basic-transport-belt",
|
||||
["underground-belt"]: "Basic-transport-belt-to-ground",
|
||||
@@ -224,5 +218,4 @@ var imagedata = {
|
||||
["piercing-shotgun-shells"]: "Piercing-shotgun-shell",
|
||||
["accumulator"]: "Basic-accumulator",
|
||||
["beacon"]: "Basic-beacon",
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user