mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Housekeeping, more config settings
This commit is contained in:
1 parent
234e6eba4c
commit
2234d41655
4 files changed
+54
-44
No files matched your search
@@ -6,6 +6,10 @@ var child_process = require('child_process');
|
|||||||
var config = require('./config');
|
var config = require('./config');
|
||||||
|
|
||||||
var instance = process.argv[2];
|
var instance = process.argv[2];
|
||||||
|
if(!instance){
|
||||||
|
console.error("Usage: node client.js [instance name]")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
var instancedirectory = './instances/'+instance;
|
var instancedirectory = './instances/'+instance;
|
||||||
if (!fs.existsSync(instancedirectory)){
|
if (!fs.existsSync(instancedirectory)){
|
||||||
fs.mkdirSync(instancedirectory);
|
fs.mkdirSync(instancedirectory);
|
||||||
@@ -20,39 +24,39 @@ read-data=__PATH__executable__\\..\\..\\data\r\n\
|
|||||||
write-data=__PATH__executable__\\..\\..\\..\\instances\\"+instance+"\r\n\
|
write-data=__PATH__executable__\\..\\..\\..\\instances\\"+instance+"\r\n\
|
||||||
");
|
");
|
||||||
|
|
||||||
var instconf = {
|
var instconf = {
|
||||||
"factorioPort": "35001",
|
"factorioPort": "35001",
|
||||||
"clientPort": "35002",
|
"clientPort": "35002",
|
||||||
"clientPassword": "clusterio"
|
"clientPassword": "clusterio"
|
||||||
}
|
}
|
||||||
fs.writeFileSync(instancedirectory + "/config.json", JSON.stringify(instconf, null, 4));
|
fs.writeFileSync(instancedirectory + "/config.json", JSON.stringify(instconf, null, 4));
|
||||||
|
|
||||||
var serversettings = {
|
var serversettings = {
|
||||||
"name": config.username +"'s clusterio "+instance,
|
"name": config.username +"'s clusterio "+instance,
|
||||||
"description": "",
|
"description": config.description,
|
||||||
"tags": ["clusterio"],
|
"tags": ["clusterio"],
|
||||||
"max_players": "20",
|
"max_players": "20",
|
||||||
"visibility": "lan",
|
"visibility": "lan",
|
||||||
"username": config.username,
|
"username": config.username,
|
||||||
"token": config.usertoken,
|
"token": config.usertoken,
|
||||||
"game_password": "",
|
"game_password": config.game_password,
|
||||||
"verify_user_identity": true,
|
"verify_user_identity": config.verify_user_identity,
|
||||||
"admins":[config.username],
|
"admins":[config.username],
|
||||||
"allow_commands":"admins-only",
|
"allow_commands":config.allow_commands,
|
||||||
"autosave_interval":10,
|
"autosave_interval":10,
|
||||||
"autosave_slots":5,
|
"autosave_slots":5,
|
||||||
"afk_autokick_interval":0,
|
"afk_autokick_interval":0,
|
||||||
"auto_pause":false
|
"auto_pause":config.auto_pause
|
||||||
}
|
}
|
||||||
fs.writeFileSync(instancedirectory + "/server-settings.json", JSON.stringify(serversettings, null, 4));
|
fs.writeFileSync(instancedirectory + "/server-settings.json", JSON.stringify(serversettings, null, 4));
|
||||||
|
|
||||||
var createSave = child_process.spawnSync(
|
var createSave = child_process.spawnSync(
|
||||||
'./factorio/bin/x64/factorio.exe',
|
'./' + config.factorioDirectory + '/bin/x64/factorio.exe',
|
||||||
[
|
[
|
||||||
'-c',instancedirectory+'/config.ini',
|
'-c',instancedirectory+'/config.ini',
|
||||||
'--create',instancedirectory+'/save.zip',
|
'--create',instancedirectory+'/save.zip',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var instanceconfig = require(instancedirectory+'/config');
|
var instanceconfig = require(instancedirectory+'/config');
|
||||||
@@ -66,7 +70,7 @@ process.on('SIGINT', function() {
|
|||||||
|
|
||||||
//var serverprocess = child_process.exec(commandline)
|
//var serverprocess = child_process.exec(commandline)
|
||||||
var serverprocess = child_process.spawn(
|
var serverprocess = child_process.spawn(
|
||||||
'./factorio/bin/x64/factorio.exe',
|
'./' + config.factorioDirectory + '/bin/x64/factorio.exe',
|
||||||
[
|
[
|
||||||
'-c',instancedirectory+'/config.ini',
|
'-c',instancedirectory+'/config.ini',
|
||||||
'--start-server',instancedirectory+'/save.zip',
|
'--start-server',instancedirectory+'/save.zip',
|
||||||
@@ -222,6 +226,7 @@ setInterval(function() {
|
|||||||
// after fetching all the latest frames, we take a timestamp. During the next iteration, we fetch all frames submitted after this.
|
// after fetching all the latest frames, we take a timestamp. During the next iteration, we fetch all frames submitted after this.
|
||||||
lastSignalCheck = Date.now();
|
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
|
// 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");
|
signals = fs.readFileSync(instancedirectory + "/script-output/txbuffer.txt", "utf8").split("\n");
|
||||||
// if we actually got anything from the file, proceed and reset file
|
// 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",
|
"masterIP": "localhost",
|
||||||
"masterPort": 8080,
|
"masterPort": 8080,
|
||||||
"__comment": "credentials for factorio MP services",
|
|
||||||
"username": "",
|
"__comment": "credentials for factorio MP services",
|
||||||
"usertoken": ""
|
"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",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.15.2",
|
"body-parser": "^1.15.2",
|
||||||
|
"child_process": "^1.0.2",
|
||||||
"express": "^4.14.0",
|
"express": "^4.14.0",
|
||||||
"fs": "0.0.2",
|
"fs": "0.0.2",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
|
|||||||
+1
-8
@@ -183,14 +183,8 @@ setInterval(function() {
|
|||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
// image data
|
// 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 = {
|
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",
|
["empty-barrel"]: "Barrel-empty",
|
||||||
["transport-belt"]: "Basic-transport-belt",
|
["transport-belt"]: "Basic-transport-belt",
|
||||||
["underground-belt"]: "Basic-transport-belt-to-ground",
|
["underground-belt"]: "Basic-transport-belt-to-ground",
|
||||||
@@ -224,5 +218,4 @@ var imagedata = {
|
|||||||
["piercing-shotgun-shells"]: "Piercing-shotgun-shell",
|
["piercing-shotgun-shells"]: "Piercing-shotgun-shell",
|
||||||
["accumulator"]: "Basic-accumulator",
|
["accumulator"]: "Basic-accumulator",
|
||||||
["beacon"]: "Basic-beacon",
|
["beacon"]: "Basic-beacon",
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user