Fixed game status monitoring.

Switched to version-safe regex for monitoring game launch progress.
Game output is now encoded in utf-8 to avoid multiple conversions from Uint8Array to String.
Note that game output has line breaks. Trim any content before testing it against regular expressions.
This commit is contained in:
Daniel Scalzi
2018-08-13 08:25:25 -04:00
parent 4f416220c2
commit f1d89c0e6b
2 changed files with 39 additions and 35 deletions

View File

@@ -37,9 +37,8 @@ class ProcessBuilder {
const tempNativePath = path.join(os.tmpdir(), ConfigManager.getTempNativeFolder(), crypto.pseudoRandomBytes(16).toString('hex'))
process.throwDeprecation = true
this.setupLiteLoader()
console.log('using liteloader', this.usingLiteLoader)
console.log('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Using liteloader:', this.usingLiteLoader)
const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.getID()).mods, this.server.getModules())
console.log(modObj)
this.constructModList('forge', modObj.fMods, true)
if(this.usingLiteLoader){
this.constructModList('liteloader', modObj.lMods, true)
@@ -58,19 +57,21 @@ class ProcessBuilder {
child.unref()
}
child.stdout.setEncoding('utf8')
child.stdout.on('data', (data) => {
console.log('Minecraft:', data.toString('utf8'))
console.log('%c[Minecraft]', 'color: #36b030; font-weight: bold', data)
})
child.stderr.on('data', (data) => {
console.log('Minecraft:', data.toString('utf8'))
console.log('%c[Minecraft]', 'color: #36b030; font-weight: bold', data)
})
child.on('close', (code, signal) => {
console.log('Exited with code', code)
console.log('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Exited with code', code)
rimraf(tempNativePath, (err) => {
if(err){
console.warn('Error while deleting temp dir', err)
console.warn('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Error while deleting temp dir', err)
} else {
console.log('Temp dir deleted successfully.')
console.log('%c[ProcessBuilder]', 'color: #003996; font-weight: bold', 'Temp dir deleted successfully.')
}
})
})