Beispiel #1
0
        server.stop(function (err) {
            assert.ifError(err)

            var connection = jvmpin.createConnection(port, addr)
            connection.on("error", function () { done() })
            connection.on("connect", function () {
                assert.fail("Connected to stopped Nailgun server‽")
            })
        })
Beispiel #2
0
    it("ensures a server is not already running and kills it if it is", function (done) {
        var connection = jvmpin.createConnection(port, addr)

        // If the server isn't running, we should get a connection
        // refused error.
        connection.on("error", function (err) {
            assert.strictEqual(err.code, "ECONNREFUSED")
            done()
        })

        // If there's a server already running, let's get it killed.
        connection.on("connect", function () {
            // Kill the existing Nailgun server process.
            connection.spawn("ng-stop", [])

            // Wait for connection close instead of process exit because
            // the Nailgun server is probably immediately shutting down.
            connection.on("close", function () {
                // To be on the safe side, try to wait for server to fully
                // exit before proceeding to next test.
                setTimeout(done, 500)
            })
        })
    })