mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Move loading of config in master to startServer
Move the loading of the config file in the master server to the startServer function. Remove config.json.test as it's no longer needed.
This commit is contained in:
1 parent
651b09b613
commit
35546b4b18
4 files changed
+14
-53
No files matched your search
@@ -4,7 +4,6 @@ node_js:
|
|||||||
before_install:
|
before_install:
|
||||||
- curl -o factorio.tar.gz -L https://www.factorio.com/get-download/latest/headless/linux64
|
- curl -o factorio.tar.gz -L https://www.factorio.com/get-download/latest/headless/linux64
|
||||||
- tar -xf factorio.tar.gz
|
- tar -xf factorio.tar.gz
|
||||||
- cp -n config.json.test config.json
|
|
||||||
- npm install -g codecov
|
- npm install -g codecov
|
||||||
script:
|
script:
|
||||||
- npm run-script ci-cover
|
- npm run-script ci-cover
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"factorioDirectory": "./factorio",
|
|
||||||
"instanceDirectory": "./instances",
|
|
||||||
"databaseDirectory": "./database",
|
|
||||||
|
|
||||||
"publicIP": "localhost",
|
|
||||||
|
|
||||||
"masterIP": "localhost",
|
|
||||||
|
|
||||||
"masterPort": 8080,
|
|
||||||
|
|
||||||
"sslPort": 443,
|
|
||||||
"sslCert": "database/certificates/cert.crt",
|
|
||||||
"sslPrivKey": "database/certificates/cert.key",
|
|
||||||
"masterAuthToken": "",
|
|
||||||
"masterAuthSecret": "TestSecretDoNotUse",
|
|
||||||
|
|
||||||
"username": "",
|
|
||||||
"token": "",
|
|
||||||
"factorio_version": "0.16.41",
|
|
||||||
|
|
||||||
"verify_user_identity": true,
|
|
||||||
"auto_pause": false,
|
|
||||||
"allow_commands": "admins-only",
|
|
||||||
"game_password": "",
|
|
||||||
"description": "This server runs Clusterio",
|
|
||||||
"visibility": {
|
|
||||||
"public": true,
|
|
||||||
"lan": true
|
|
||||||
},
|
|
||||||
|
|
||||||
"itemStats": {
|
|
||||||
"maxEntries":60,
|
|
||||||
"entriesPerSecond": 0.01666666667
|
|
||||||
},
|
|
||||||
"logItemTransfers": false,
|
|
||||||
"disableFairItemDistribution": true,
|
|
||||||
"useNeuralNetDoleDivider": false,
|
|
||||||
"uploadModsToMaster": true,
|
|
||||||
"msBetweenCommands": 10,
|
|
||||||
"allowRemoteCommandExecution": true,
|
|
||||||
"enableCrossServerShout": true,
|
|
||||||
"mirrorAllChat": false,
|
|
||||||
"autosaveInterval": 600000,
|
|
||||||
"disableImportsOfEverythingExceptElectricity": false
|
|
||||||
}
|
|
||||||
@@ -28,8 +28,7 @@ const moment = require("moment");
|
|||||||
const request = require("request");
|
const request = require("request");
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
console.log(`Requiring config from ${args.config || './config'}`);
|
let config = {};
|
||||||
const config = require(args.config || './config');
|
|
||||||
|
|
||||||
// homebrew modules
|
// homebrew modules
|
||||||
const generateSSLcert = require("lib/generateSSLcert");
|
const generateSSLcert = require("lib/generateSSLcert");
|
||||||
@@ -865,6 +864,9 @@ async function startServer() {
|
|||||||
// add better stack traces on promise rejection
|
// add better stack traces on promise rejection
|
||||||
process.on('unhandledRejection', r => console.log(r));
|
process.on('unhandledRejection', r => console.log(r));
|
||||||
|
|
||||||
|
console.log(`Requiring config from ${args.config || './config'}`);
|
||||||
|
config = require(args.config || './config');
|
||||||
|
|
||||||
/** Sync */
|
/** Sync */
|
||||||
function randomStringAsBase64Url(size) {
|
function randomStringAsBase64Url(size) {
|
||||||
return base64url(crypto.randomBytes(size));
|
return base64url(crypto.randomBytes(size));
|
||||||
@@ -964,6 +966,7 @@ module.exports = {
|
|||||||
|
|
||||||
// For testing only
|
// For testing only
|
||||||
_db: db,
|
_db: db,
|
||||||
|
_config: config,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module === require.main) {
|
if (module === require.main) {
|
||||||
|
|||||||
+9
-4
@@ -5,17 +5,22 @@ const parallel = require('mocha.parallel');
|
|||||||
const jwt = require("jsonwebtoken");
|
const jwt = require("jsonwebtoken");
|
||||||
|
|
||||||
const master = require('./master.js');
|
const master = require('./master.js');
|
||||||
const config = require('./config.json');
|
|
||||||
const authenticate = require('lib/authenticate');
|
const authenticate = require('lib/authenticate');
|
||||||
const database = require('lib/database');
|
const database = require('lib/database');
|
||||||
|
|
||||||
|
|
||||||
authenticate.setAuthSecret(config.masterAuthSecret);
|
|
||||||
master._db.slaves = new Map();
|
master._db.slaves = new Map();
|
||||||
master._db.items = new database.ItemDatabase();
|
master._db.items = new database.ItemDatabase();
|
||||||
|
|
||||||
const token =
|
// Fields required in the config
|
||||||
jwt.sign( { id: "api" }, config.masterAuthSecret, { expiresIn: 600 });
|
master._config.factorioDirectory = "factorio";
|
||||||
|
master._config.itemStats = { maxEntries:60, entriesPerSecond: 1 / 60 };
|
||||||
|
master._config.disableFairItemDistribution = true;
|
||||||
|
|
||||||
|
const testSecret = "TestSecretDoNotUse";
|
||||||
|
authenticate.setAuthSecret(testSecret);
|
||||||
|
|
||||||
|
const token = jwt.sign({ id: "api" }, testSecret, { expiresIn: 600 });
|
||||||
|
|
||||||
async function get(path) {
|
async function get(path) {
|
||||||
return await request(master.app).get(path).expect(200);
|
return await request(master.app).get(path).expect(200);
|
||||||
|
|||||||
Reference in new issue
Block a user