mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Delay headless clients startup until server is started
This commit is contained in:
parent
cf5bfd4cf0
commit
30e7a8cdb0
16
lib/logs.js
16
lib/logs.js
@ -135,18 +135,6 @@ Logs.prototype.readLogFile = function (filename, callback) {
|
||||
fs.readFile(filename, callback)
|
||||
}
|
||||
|
||||
Logs.prototype.logServerProcesses = function (prefix, serverProcess, headlessClientProcesses) {
|
||||
var self = this
|
||||
this.logServerProcess(serverProcess, prefix, 'server')
|
||||
headlessClientProcesses.forEach(function (headlessClientProcess, idx) {
|
||||
self.logServerProcess(headlessClientProcess, prefix, 'hc_' + (idx + 1))
|
||||
})
|
||||
|
||||
if (this.config.type === 'linux') {
|
||||
this.cleanupOldLogFiles()
|
||||
}
|
||||
}
|
||||
|
||||
Logs.prototype.logServerProcess = function (serverProcess, prefix, suffix) {
|
||||
if (this.config.type !== 'linux') {
|
||||
return
|
||||
@ -183,6 +171,10 @@ Logs.prototype.logServerProcess = function (serverProcess, prefix, suffix) {
|
||||
}
|
||||
|
||||
Logs.prototype.cleanupOldLogFiles = function () {
|
||||
if (this.config.type !== 'linux') {
|
||||
return
|
||||
}
|
||||
|
||||
var self = this
|
||||
|
||||
self.logFiles(function (err, files) {
|
||||
|
@ -89,6 +89,7 @@ Server.prototype.queryStatus = function () {
|
||||
self.state = null
|
||||
} else {
|
||||
self.state = state
|
||||
self.startHeadlessClientsIfNeeded()
|
||||
}
|
||||
|
||||
self.emit('state')
|
||||
@ -178,19 +179,25 @@ Server.prototype.start = function () {
|
||||
|
||||
this.pid = instance.pid
|
||||
this.instance = instance
|
||||
this.headlessClientInstances = []
|
||||
this.queryStatusInterval = setInterval(function () {
|
||||
self.queryStatus()
|
||||
}, queryInterval)
|
||||
|
||||
this.startHeadlessClients()
|
||||
|
||||
this.logs.logServerProcesses(this.id, this.instance, this.headlessClientInstances)
|
||||
this.logs.logServerProcess(this.instance, this.id, 'server')
|
||||
this.logs.cleanupOldLogFiles()
|
||||
|
||||
this.emit('state')
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
Server.prototype.startHeadlessClientsIfNeeded = function () {
|
||||
if (this.number_of_headless_clients > 0 && this.headlessClientInstances.length === 0) {
|
||||
this.startHeadlessClients()
|
||||
}
|
||||
}
|
||||
|
||||
Server.prototype.startHeadlessClients = function () {
|
||||
var parameters = this.getParameters()
|
||||
var self = this
|
||||
@ -207,6 +214,7 @@ Server.prototype.startHeadlessClients = function () {
|
||||
port: self.port
|
||||
})
|
||||
var headlessInstance = headless.start()
|
||||
self.logs.logServerProcess(headlessInstance, self.id, 'hc_' + (i + 1))
|
||||
return headlessInstance
|
||||
})
|
||||
|
||||
@ -245,6 +253,7 @@ Server.prototype.stopHeadlessClients = function () {
|
||||
this.headlessClientInstances.map(function (headlessClientInstance) {
|
||||
headlessClientInstance.kill()
|
||||
})
|
||||
this.headlessClientInstances = []
|
||||
}
|
||||
|
||||
Server.prototype.toJSON = function () {
|
||||
|
Loading…
Reference in New Issue
Block a user