Skip to content

Commit 47d30d4

Browse files
authored
Added option for custom Log Directory (#1)
1 parent b851139 commit 47d30d4

File tree

7 files changed

+19
-3
lines changed

7 files changed

+19
-3
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Key | Description
4242
--- | ---
4343
game | Which game server to launch, see above
4444
path | Folder path to game server
45+
logpath | Folder path to the server's logs
4546
port | Web port to use
4647
host | IP or Hostname to listen on
4748
type | Which kind of server to use, can be 'linux', 'windows' or 'wine'

Diff for: app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var missions = new Missions(config)
3838
var mods = new Mods(config)
3939
mods.updateMods()
4040

41-
var settings = new Settings(config)
41+
var settings = new Settings(config, logs)
4242

4343
app.use('/api/logs', require('./routes/logs')(logs))
4444
app.use('/api/missions', require('./routes/missions')(missions))

Diff for: config.js.example

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
game: 'arma3', // arma3, arma2oa, arma2, arma1, cwa, ofpresistance, ofp
33
path: 'path-to-arma3-directory',
4+
logpath: '', // fill this value if you require a custom log directory
45
port: 3000,
56
host: '0.0.0.0', // Can be either an IP or a Hostname
67
type: 'linux', // Can be either linux, windows or wine

Diff for: lib/logs.js

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ Logs.prototype.generateLogFilePath = function (prefix, suffix) {
5151
}
5252

5353
Logs.prototype.logsPath = function () {
54+
if (this.config.logpath != '') {
55+
return this.config.logpath;
56+
}
57+
5458
if (this.config.type === 'linux') {
5559
return path.join(this.config.path, 'logs')
5660
}

Diff for: lib/server.js

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Server.prototype.start = function () {
153153
password: this.password,
154154
passwordAdmin: this.admin_password,
155155
path: this.config.path,
156+
logpath: this.config.logpath,
156157
persistent: this.persistent ? 1 : 0,
157158
platform: this.config.type,
158159
players: this.max_players,
@@ -208,6 +209,7 @@ Server.prototype.startHeadlessClients = function () {
208209
parameters: parameters,
209210
password: self.password,
210211
path: self.config.path,
212+
logpath: self.config.logpath,
211213
platform: self.config.type,
212214
port: self.port
213215
})

Diff for: lib/settings.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
var _ = require('lodash')
22

3-
var Settings = function (config) {
3+
var Settings = function (config, logs) {
44
this.config = config
5+
this.config.logpath = logs.logsPath()
56
}
67

78
Settings.prototype.getPublicSettings = function () {
8-
return _.pick(this.config, ['game', 'path', 'type'])
9+
return _.pick(this.config, ['game', 'path', 'logpath', 'type'])
910
}
1011

1112
module.exports = Settings

Diff for: public/js/tpl/settings.html

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
</div>
77
</div>
88

9+
<div class="form-group">
10+
<label for="logpath" class="col-sm-2 control-label">Logs Path</label>
11+
<div class="col-sm-10">
12+
<input type="text" class="form-control" placeholder="Logs Path" disabled value="<%- logpath %>">
13+
</div>
14+
</div>
15+
916
<div class="form-group">
1017
<label for="type" class="col-sm-2 control-label">Type</label>
1118
<div class="col-sm-10">

0 commit comments

Comments
 (0)