24 lines
491 B
JavaScript
24 lines
491 B
JavaScript
import { createServer } from 'http';
|
|
|
|
var app = createServer(function (req, res) {
|
|
res.writeHead(200);
|
|
setTimeout(() => {
|
|
res.end('hey');
|
|
}, 2000);
|
|
});
|
|
|
|
var listener = app.listen(0, function () {
|
|
console.log('Listening on port ' + listener.address().port);
|
|
setTimeout(() => {
|
|
// Here we send the ready signal to PM2
|
|
process.send('ready');
|
|
}, 5000);
|
|
});
|
|
|
|
process.on('SIGINT', function () {
|
|
listener.close();
|
|
setTimeout(() => {
|
|
process.exit(0);
|
|
}, 2000);
|
|
});
|