From 1eb4c04cedb530d26b52b2a84cf4eda2aa47d6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Dahlgren?= Date: Mon, 24 Nov 2014 01:56:54 +0100 Subject: [PATCH] Linux compability in manager --- manager.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/manager.js b/manager.js index d099f43..f7d5b6c 100644 --- a/manager.js +++ b/manager.js @@ -66,6 +66,14 @@ Server.prototype.queryStatus = function() { Server.prototype.start = function() { var startParams = []; var gamePath = this.armaServerPath(); + var options = null; + + if (config.type === "linux") { + options = { + cwd: config.path, + env: process.env, + }; + } if (config.type === "wine") { gamePath = "wine"; @@ -84,29 +92,29 @@ Server.prototype.start = function() { console.log(gamePath); console.log(startParams); - var process = spawn(gamePath, startParams); + var instance = spawn(gamePath, startParams, options); var self = this; - process.stdout.on('data', function (data) { + instance.stdout.on('data', function (data) { console.log('stdout: ' + data); }); - process.stderr.on('data', function (data) { + instance.stderr.on('data', function (data) { console.log('stderr: ' + data); }); - process.on('close', function (code) { + instance.on('close', function (code) { console.log('child process exited with code ' + code); clearInterval(self.queryStatusInterval); self.state = null; self.pid = null; - self.process = null; + self.instance = null; self.emit('state'); }); - this.pid = process.pid; - this.process = process; + this.pid = instance.pid; + this.instance = instance; this.queryStatusInterval = setInterval(function () { self.queryStatus(); }, queryInterval); @@ -120,7 +128,7 @@ Server.prototype.stop = function(cb) { var handled = false; var self = this; - this.process.on('close', function (code) { + this.instance.on('close', function (code) { if (!handled) { handled = true; @@ -130,7 +138,7 @@ Server.prototype.stop = function(cb) { } }); - this.process.kill(); + this.instance.kill(); setTimeout(function() { if (!handled) {