0

I have a Hapi installation which uses good as a logging plugin and good-logstash-tcp extension to send logs to logstash.

My current problem is that logstash server may sometimes be unavailable, and that currently causes the whole server to crash with an error like the following:

/.../node_modules/good-logstash-tcp/lib/logstash.js:178
            self.emit('error', new Error('Max retries reached, transport in silent mode, OFFLINE'));
                               ^
Error: Max retries reached, transport in silent mode, OFFLINE
    at Socket.<anonymous> (/.../node_modules/good-logstash-tcp/lib/logstash.js:178:36)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at TCP._handle.close [as _onclose] (net.js:511:12)

Is there an easy way to make Hapi keep on running even if logging fails for some reason?

Alex Kiselev
  • 552
  • 2
  • 7
  • 22

1 Answers1

0

Use an utility like pm2 or nodemon to automatically restart your Node application after an error.

Example with nodemon:

1) Install it with npm install -g nodemon

2) Run your app with nodemon index.js instead of node index.js or npm start

Veve
  • 6,643
  • 5
  • 39
  • 58