improve ecosystem file and only signal PM2 _after_ listening

merge-requests/208/head
fatchan 5 years ago
parent efa57023e7
commit 38c72dd5ce
  1. 4
      ecosystem.config.js
  2. 13
      server.js

@ -9,8 +9,8 @@ module.exports = {
max_memory_restart: '1G',
log_date_format: 'YYYY-MM-DD HH:mm:ss',
wait_ready: true,
listen_timeout: 10000,
kill_timeout: 10000,
listen_timeout: 5000,
kill_timeout: 5000,
env: {
NODE_ENV: 'development'
},

@ -96,13 +96,16 @@ const express = require('express')
// listen
const server = app.listen(configs.port, '127.0.0.1', () => {
console.log(`Listening on port ${configs.port}`);
});
//let PM2 know that this is ready (for graceful reloads)
if (typeof process.send === 'function') { //make sure we are a child process
process.send('ready');
}
//let PM2 know that this is ready (for graceful reloads)
if (typeof process.send === 'function') { //make sure we are a child process
console.info('Sending ready signal to PM2')
process.send('ready');
}
});
process.on('SIGINT', () => {

Loading…
Cancel
Save