Skip to content

Commit

Permalink
Added option for custom Log Directory (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrschick authored Mar 16, 2023
1 parent b851139 commit 47d30d4
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Key | Description
--- | ---
game | Which game server to launch, see above
path | Folder path to game server
logpath | Folder path to the server's logs
port | Web port to use
host | IP or Hostname to listen on
type | Which kind of server to use, can be 'linux', 'windows' or 'wine'
Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var missions = new Missions(config)
var mods = new Mods(config)
mods.updateMods()

var settings = new Settings(config)
var settings = new Settings(config, logs)

app.use('/api/logs', require('./routes/logs')(logs))
app.use('/api/missions', require('./routes/missions')(missions))
Expand Down
1 change: 1 addition & 0 deletions config.js.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
game: 'arma3', // arma3, arma2oa, arma2, arma1, cwa, ofpresistance, ofp
path: 'path-to-arma3-directory',
logpath: '', // fill this value if you require a custom log directory
port: 3000,
host: '0.0.0.0', // Can be either an IP or a Hostname
type: 'linux', // Can be either linux, windows or wine
Expand Down
4 changes: 4 additions & 0 deletions lib/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Logs.prototype.generateLogFilePath = function (prefix, suffix) {
}

Logs.prototype.logsPath = function () {
if (this.config.logpath != '') {
return this.config.logpath;
}

if (this.config.type === 'linux') {
return path.join(this.config.path, 'logs')
}
Expand Down
2 changes: 2 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Server.prototype.start = function () {
password: this.password,
passwordAdmin: this.admin_password,
path: this.config.path,
logpath: this.config.logpath,
persistent: this.persistent ? 1 : 0,
platform: this.config.type,
players: this.max_players,
Expand Down Expand Up @@ -208,6 +209,7 @@ Server.prototype.startHeadlessClients = function () {
parameters: parameters,
password: self.password,
path: self.config.path,
logpath: self.config.logpath,
platform: self.config.type,
port: self.port
})
Expand Down
5 changes: 3 additions & 2 deletions lib/settings.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var _ = require('lodash')

var Settings = function (config) {
var Settings = function (config, logs) {
this.config = config
this.config.logpath = logs.logsPath()
}

Settings.prototype.getPublicSettings = function () {
return _.pick(this.config, ['game', 'path', 'type'])
return _.pick(this.config, ['game', 'path', 'logpath', 'type'])
}

module.exports = Settings
7 changes: 7 additions & 0 deletions public/js/tpl/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
</div>
</div>

<div class="form-group">
<label for="logpath" class="col-sm-2 control-label">Logs Path</label>
<div class="col-sm-10">
<input type="text" class="form-control" placeholder="Logs Path" disabled value="<%- logpath %>">
</div>
</div>

<div class="form-group">
<label for="type" class="col-sm-2 control-label">Type</label>
<div class="col-sm-10">
Expand Down

0 comments on commit 47d30d4

Please sign in to comment.