From d1d68b7a268beb846bff6db3724586ad86c95d3d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 3 Dec 2015 16:15:05 -0800 Subject: [PATCH] Add logging to console --- console/main.js | 13 +++++++------ console/modules/hf-process.js | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/console/main.js b/console/main.js index ee79c434e0..95180736bc 100644 --- a/console/main.js +++ b/console/main.js @@ -71,12 +71,13 @@ app.on('ready', function() { var acPath = 'C:\\Users\\Ryan\\AppData\\Local\\High Fidelity\\Stack Manager\\assignment-client.exe'; var homeServer = new ProcessGroup('home', [ - new Process('Domain Server', domainServerPath), - new Process('AC - Audio', acPath, ['-t0']), - new Process('AC - Avatar', acPath, ['-t1']), - new Process('AC - Asset', acPath, ['-t3']), - new Process('AC - Messages', acPath, ['-t4']), - new Process('AC - Entity', acPath, ['-t6']) + new Process('domain_server', domainServerPath), + new Process('ac_audio', acPath, ['-t0']), + new Process('ac_avatar', acPath, ['-t1']), + new Process('ac_agent', acPath, ['-t2']), + new Process('ac_asset', acPath, ['-t3']), + new Process('ac_messages', acPath, ['-t4']), + new Process('ac_entity', acPath, ['-t6']) ]); homeServer.start(); diff --git a/console/modules/hf-process.js b/console/modules/hf-process.js index d906d3058b..638f61cb2a 100755 --- a/console/modules/hf-process.js +++ b/console/modules/hf-process.js @@ -4,6 +4,7 @@ var extend = require('extend'); var util = require('util'); var events = require('events'); var childProcess = require('child_process'); +var fs = require('fs'); const ProcessGroupStates = { STOPPED: 'stopped', @@ -95,10 +96,25 @@ Process.prototype = extend(Process.prototype, { } console.log("Starting " + this.command); try { + var time = (new Date).getTime(); + console.log('time', time); + var tmpLogStdout = './logs/' + this.name + "-" + time + "-stdout.txt"; + var tmpLogStderr = './logs/' + this.name + "-" + time + "-stderr.txt"; + + var logStdout = fs.openSync(tmpLogStdout, 'ax'); + var logStderr = fs.openSync(tmpLogStderr, 'ax'); + this.child = childProcess.spawn(this.command, this.commandArgs, { - detached: false + detached: false, + stdio: ['ignore', logStdout, logStderr] }); - //console.log("started ", this.child); + + var pidLogStdout = './logs/' + this.name + "-" + this.child.pid + "-stdout.txt"; + var pidLogStderr = './logs/' + this.name + "-" + this.child.pid + "-stderr.txt"; + + fs.rename(tmpLogStdout, pidLogStdout, function(e) { }); + fs.rename(tmpLogStderr, pidLogStderr, function(e) { }); + this.child.on('error', this.onChildStartError.bind(this)); this.child.on('close', this.onChildClose.bind(this)); this.state = ProcessStates.STARTED;