From 1ec33dd40c0a7f3c14d456d3aa470ae7dbade421 Mon Sep 17 00:00:00 2001 From: Stuart Mitchell Date: Thu, 14 Aug 2014 12:14:53 +1200 Subject: [PATCH 1/4] change to how the callback on nrepl close is handled --- nrepl-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nrepl-server.js b/nrepl-server.js index f9edc99..4d948c7 100644 --- a/nrepl-server.js +++ b/nrepl-server.js @@ -49,8 +49,8 @@ function stopServer(port, thenDo) { console.log("nREPL server shutdown"); thenDo(null); return; } console.log("Stopping nREPL server with pid %s", serverProc.pid); + serverProc.on('close', thenDo); kill(serverProc.pid, 'SIGKILL'); - thenDo(null); } module.exports = { From 1cc6fd78cd2f9bbe7d79bd5f0e9a61b493440bfb Mon Sep 17 00:00:00 2001 From: Stuart Mitchell Date: Thu, 14 Aug 2014 16:54:30 +1200 Subject: [PATCH 2/4] use spawn-cmd for windows compatibility --- nrepl-server.js | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nrepl-server.js b/nrepl-server.js index 4d948c7..f7d5d53 100644 --- a/nrepl-server.js +++ b/nrepl-server.js @@ -7,7 +7,7 @@ */ var path = require("path"); -var spawn = require("child_process").spawn; +var spawn = require("spawn-cmd").spawn; var kill = require('tree-kill'); var verbose = false, serverProc; diff --git a/package.json b/package.json index ac82f97..ecf9ff3 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "license": "MIT", "dependencies": { "bencode": "~0.4.3", - "tree-kill": "~0.0.6" + "tree-kill": "~0.0.6", + "spawn-cmd": "~0.0.2" }, "devDependencies": { "async": "~0.2", From d101fd673def532159f76572d06d6f593304ffca Mon Sep 17 00:00:00 2001 From: Stuart Mitchell Date: Tue, 9 Dec 2014 15:46:36 +1300 Subject: [PATCH 3/4] rebased changes on new master --- src/nrepl-server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nrepl-server.js b/src/nrepl-server.js index 756e169..cd69200 100644 --- a/src/nrepl-server.js +++ b/src/nrepl-server.js @@ -10,6 +10,7 @@ var path = require("path"); var ps = require("child_process"); var util = require("util"); +var spawn = require("spawn-cmd").spawn var merge = util._extend; // note, the JVM will stick around when we just kill the spawning process @@ -96,7 +97,7 @@ function startServer(hostname, port, projectPath, thenDo) { var procArgs = ["repl", ":headless"]; if (hostname) procArgs = procArgs.concat([':host', hostname]); if (port) procArgs = procArgs.concat([':port', port]); - var proc = ps.spawn('lein', procArgs, {cwd: projectPath}); + var proc = spawn('lein', procArgs, {cwd: projectPath}); } catch (e) { thenDo(e, null); return; } thenDo(null, { proc: proc, @@ -136,10 +137,10 @@ function stop(serverState, thenDo) { if (serverState.exited) { thenDo(null); return; } // FIXME what if when kill doesn't work? At least attach to `close` and // throw a time out error... - kill(serverState.proc.pid, 'SIGTERM'); serverState.proc.once('close', function() { console.log("Stopped nREPL server with pid %s", serverState.proc.pid); thenDo && thenDo(null); + kill(serverState.proc.pid, 'SIGTERM'); }); } From da80634e194ff590b74b507fc0a781edd12e1826 Mon Sep 17 00:00:00 2001 From: Stuart Mitchell Date: Tue, 9 Dec 2014 15:53:18 +1300 Subject: [PATCH 4/4] reverted changed to stop server --- src/nrepl-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nrepl-server.js b/src/nrepl-server.js index cd69200..8405b51 100644 --- a/src/nrepl-server.js +++ b/src/nrepl-server.js @@ -137,10 +137,10 @@ function stop(serverState, thenDo) { if (serverState.exited) { thenDo(null); return; } // FIXME what if when kill doesn't work? At least attach to `close` and // throw a time out error... + kill(serverState.proc.pid, 'SIGTERM'); serverState.proc.once('close', function() { console.log("Stopped nREPL server with pid %s", serverState.proc.pid); thenDo && thenDo(null); - kill(serverState.proc.pid, 'SIGTERM'); }); }