From 2f54e124701ed910fc173bc803283aa3b9eea280 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 15 Jul 2019 15:02:59 -0400 Subject: [PATCH] clone, keep process env vars --- libs/processRunner.js | 9 ++++----- libs/utils.js | 4 ++++ services/nodeodm.service | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/processRunner.js b/libs/processRunner.js index 59897a1..8e50c1a 100644 --- a/libs/processRunner.js +++ b/libs/processRunner.js @@ -22,6 +22,7 @@ let assert = require('assert'); let spawn = require('child_process').spawn; let config = require('../config.js'); let logger = require('./logger'); +let utils = require('./utils'); function makeRunner(command, args, requiredOptions = [], outputTestFile = null){ @@ -58,11 +59,9 @@ function makeRunner(command, args, requiredOptions = [], outputTestFile = null){ } // Launch - let childProcess = spawn(command, commandArgs, { - env:{ - LD_LIBRARY_PATH: path.join(config.odm_path, "SuperBuild", "install", "lib") - } - }); + const env = utils.clone(process.env); + env.LD_LIBRARY_PATH = path.join(config.odm_path, "SuperBuild", "install", "lib"); + let childProcess = spawn(command, commandArgs, { env }); childProcess .on('exit', (code, signal) => done(null, code, signal)) diff --git a/libs/utils.js b/libs/utils.js index 9b6a303..e749c63 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -44,5 +44,9 @@ module.exports = { const safeSuffix = path.normalize(p).replace(/^(\.\.(\/|\\|$))+/, ''); return path.join('./', safeSuffix); }); + }, + + clone: function(json){ + return JSON.parse(JSON.stringify(json)); } }; \ No newline at end of file diff --git a/services/nodeodm.service b/services/nodeodm.service index 3844bdb..921c533 100644 --- a/services/nodeodm.service +++ b/services/nodeodm.service @@ -7,7 +7,6 @@ PIDFile=/run/nodeodm.pid User=odm Group=odm WorkingDirectory=/www -Environment="HOME=/www/data" ExecStart=/usr/bin/node index.js ExecStop=/bin/kill -s QUIT $MAINPID Restart=on-failure