I am building an Express server with rechargeable endpoints.
To make this possible, I created an endpoint for such a purpose.
But when I call server.close()on the express HTTP server, it continues to listen, but server.listeningsays otherwise, it is still there.
Here is a simplified version of my script (doesn't work completely, but you get the gist):
class simpleServer {
constructor() {
let express = require('express');
this.app = express();
this.app.get('/reload', this.reload);
this.server = this.app.listen(3000);
}
reload(req, res) {
console.log('Closing server');
this.server.close(function() {
console.log('Closed server');
});
res.json({
message: 'Reloaded'
});
}
}
let server = new simpleServer();
When I call the endpoint, the server displays "Closing server", but "Closed server" is not called. And when I reload the page, it still works and server.listeningis false.
I am using Node.js version 6.0.0 with express version 4.14.0 .
I hope I have provided enough information.
thank
: " " , 5 .
2: , req.destroy() , - tho?
3: , . , , , .