Migrate to new config format in Reforger 0.9.9

This commit is contained in:
Björn Dahlgren
2023-07-20 19:27:33 +02:00
parent ab3f3ed876
commit 34a80e465e
4 changed files with 18 additions and 46 deletions

View File

@ -30,8 +30,8 @@ module.exports = {
},
reforger: {
configs: process.env.REFORGER_CONFIGS,
logs: process.env.REFORGER_LOGS,
profiles: process.env.REFORGER_PROFILES,
region: process.env.REFORGER_REGION,
workshop: process.env.REFORGER_WORKSHOP
},
prefix: process.env.SERVER_PREFIX,

View File

@ -11,8 +11,8 @@ module.exports = {
],
reforger: {
configs: 'path-to-configs-folder', // Folder where server config files will be stored
logs: 'path-to-logs-folder', // Folder where server log files will be stored
profiles: 'path-to-profiles-folder', // Folder where logs and persistence data will be stored. Each server will create a subfolder.
region: 'EU', // Region in which servers will be hosted, https://community.bistudio.com/wiki/Arma_Reforger:Server_Hosting#region
workshop: 'path-to-workshop-folder' // Folder where workshop mods will be stored
},
serverMods: [ // Mods used exclusively by server and not shared with clients

View File

@ -25,7 +25,7 @@ Logs.prototype.delete = function (filename, callback) {
}
Logs.prototype.logsPath = function () {
return this.config.reforger.profiles
return this.config.reforger.logs
}
Logs.prototype.logFiles = function (callback) {

View File

@ -36,7 +36,6 @@ Server.prototype.update = function (options) {
this.admin_password = options.admin_password
this.auto_start = options.auto_start
this.battle_eye = options.battle_eye
this.dedicatedServerId = options.dedicatedServerId
this.max_players = options.max_players
this.missions = options.missions
this.mods = options.mods || []
@ -61,7 +60,7 @@ Server.prototype.queryStatus = function () {
Gamedig.query(
{
type: 'arma3',
host: self.ip,
host: '127.0.0.1',
port: self.steamQueryPort() - 1
},
function (state) {
@ -88,20 +87,22 @@ Server.prototype.makeServerConfig = function () {
}
return {
dedicatedServerId: this.dedicatedServerId,
region: this.config.reforger.region,
gameHostBindAddress: '',
gameHostBindPort: this.port,
gameHostRegisterBindAddress: this.ip,
gameHostRegisterPort: this.port,
adminPassword: this.admin_password,
bindAddress: '',
bindPort: this.port,
publicAddress: this.ip,
publicPort: this.port,
a2s: {
address: '127.0.0.1',
port: this.steamQueryPort()
},
game: {
name: this.createServerTitle(this.title),
password: this.password,
passwordAdmin: this.admin_password,
scenarioId: scenarioId,
playerCountLimit: this.max_players,
autoJoinable: false,
maxPlayers: parseInt(this.max_players, 10),
visible: true,
crossPlatform: true,
gameProperties: {
serverMaxViewDistance: 2500,
serverMinGrassDistance: 50,
@ -115,9 +116,7 @@ Server.prototype.makeServerConfig = function () {
modId: mod
}
})
},
a2sQueryEnabled: true,
steamQueryPort: this.steamQueryPort()
}
}
}
@ -129,22 +128,6 @@ Server.prototype.serverConfigFile = function () {
return path.join(this.serverConfigDirectory(), this.generateId() + '.json')
}
Server.prototype.readServerConfig = function (cb) {
var self = this
fs.readFile(self.serverConfigFile(), 'utf8', function (err, data) {
if (err) {
return cb(err)
}
try {
var serverConfig = JSON.parse(data)
cb(null, serverConfig)
} catch (err) {
cb(err)
}
})
}
Server.prototype.saveServerConfig = function (config, cb) {
var self = this
fs.mkdirp(self.serverConfigDirectory(), function (err) {
@ -170,6 +153,8 @@ Server.prototype.serverArguments = function () {
this.config.reforger.workshop,
'-config',
this.serverConfigFile(),
'-logsDir',
path.join(this.config.reforger.logs, id),
'-profile',
path.join(this.config.reforger.profiles, id)
].map(function (argument) {
@ -233,18 +218,6 @@ Server.prototype.stop = function (cb) {
if (!handled) {
handled = true
self.readServerConfig(function (err, serverConfig) {
if (err) {
console.log(err)
return
}
if (self.dedicatedServerId !== serverConfig.dedicatedServerId) {
self.dedicatedServerId = serverConfig.dedicatedServerId
self.emit('save')
}
})
if (cb) {
cb()
}
@ -265,7 +238,6 @@ Server.prototype.toJSON = function () {
admin_password: this.admin_password,
auto_start: this.auto_start,
battle_eye: this.battle_eye,
dedicatedServerId: this.dedicatedServerId,
id: this.id,
max_players: this.max_players,
missions: this.missions,