From 0377e23c205decdfd3d9d885af7b0b4078f1448c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 5 Jan 2016 13:57:40 +0100 Subject: [test] terminate test server when stdin closes --- test/storage/server.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/storage/server.js') diff --git a/test/storage/server.js b/test/storage/server.js index 249c6a124b..a814ce15e6 100755 --- a/test/storage/server.js +++ b/test/storage/server.js @@ -2,6 +2,13 @@ /* jshint node: true */ 'use strict'; +// This needs to be here to make sure the pipe stays open. +// We're waiting until the stdin pipe gets closed (e.g. because the parent +// process dies) +process.stdin.on('readable', function() {}); +process.stdin.on('end', function() { process.exit(0); }); + + var fs = require('fs'); var express = require('express'); var app = express(); @@ -101,13 +108,6 @@ app.get('/load/:number(\\d+)', function(req, res) { }); var server = app.listen(3000, function () { - var host = server.address().address; - var port = server.address().port; - console.warn('Storage test server listening at http://%s:%s', host, port); - - if (process.argv[2]) { - // Allow the test to continue running. - fs.write(+process.argv[2], 'OK'); - fs.close(+process.argv[2]); - } + // Tell parent that we're now listening. + process.stdout.write("OK"); }); -- cgit v1.2.1