From fc68fa8216054576013520eb8282d5e792ee43ce Mon Sep 17 00:00:00 2001 From: Gordon Hall Date: Wed, 11 Jan 2017 13:03:05 -0500 Subject: [PATCH] use spawn with detached --- lib/api.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/api.js b/lib/api.js index 6095cf7..b757896 100644 --- a/lib/api.js +++ b/lib/api.js @@ -5,7 +5,7 @@ const fs = require('fs'); const {statSync, readFileSync} = require('fs'); const stripJsonComments = require('strip-json-comments'); const JsonLogger = require('kad-logger-json'); -const {fork} = require('child_process'); +const {spawn} = require('child_process'); const utils = require('./utils'); const path = require('path'); @@ -20,6 +20,7 @@ class RPC { constructor(options={}) { this.logger = new JsonLogger(options.logVerbosity); this.shares = new Map(); + this._execPath = options.execPath || 'node'; } /** @@ -98,9 +99,9 @@ class RPC { let uptimeCounter = setInterval(() => share.meta.uptimeMs += 1000, 1000); // NB: Fork the actual farmer process, passing it the configuration - share.process = fork( - path.join(__dirname, '../script/farmer.js'), - ['--config', configPath], + share.process = spawn( + self._execPath, + [path.join(__dirname, '../script/farmer.js'), '--config', configPath], { stdio: [0, 'pipe', 'pipe', 'ipc'], detached: false