Testing individual nodes launched by naught using supertest The purpose: an express node.js server which can be launched using naught, with an integration test using supertest. Each worker naught runs will test itself on a unique port, and only if passes it will listen in on the main port and join the pool. 

Major concerns are - no idea what I'm doing.  How I provision the ports for the test nodes, closing the test servers (need to clear up memory)?

This just a POC, structuring is required for a production app.

var testport = 10000 + process.pid;
var server = app.listen(testport, function() {
    console.log('pid %d listening on port %d ...', process.pid, testport);

    supertest(server)
    .get('/test')
    .expect(200)
    .end(function(err, res){

        if (err) {
            console.log(err); 
            if (process.send) process.send('offline');
            process.exit(-1);
        }
        else {
            console.log('pid %d tested OK, closing test server and launching main one...', process.pid);
            server.close();
            listenToMainport();                
        }

    });
});


You can see the full context of the example here.
I think you should write more code before submitting, the fun part to review is the code that you wrote after the prototype ;)

From a quick once over:


JsHint finds no fault except for some mixed use of tabs and space
Consider 'use strict', it can save lives
Consider something better than console.log, especially if you are going to use this code for performance testing
Use lowerCamelCase consistently: testport -> testPort