Add logging to console

This commit is contained in:
Ryan Huffman 2015-12-03 16:15:05 -08:00
parent dce9957983
commit d1d68b7a26
2 changed files with 25 additions and 8 deletions

View file

@ -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();

View file

@ -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;