diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-01-05 13:57:40 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-01-05 14:14:23 +0100 |
commit | 0377e23c205decdfd3d9d885af7b0b4078f1448c (patch) | |
tree | 75e54a9da08966a822aac95479ec938bd5564ad6 /test/storage/server.js | |
parent | 70f04c8bc5ea6869e4631aff490efe646d9d870e (diff) | |
download | qtlocation-mapboxgl-0377e23c205decdfd3d9d885af7b0b4078f1448c.tar.gz |
[test] terminate test server when stdin closes
Diffstat (limited to 'test/storage/server.js')
-rwxr-xr-x | test/storage/server.js | 18 |
1 files changed, 9 insertions, 9 deletions
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"); }); |