logging - Winston logger - Is it possible to log the shut down of an application -


in winston logger node js, possible log shut down of node application? example, if node app run in docker, , docker container killed, possible log winston? or need log through docker?

you can capture signal events in node.js , run any code on signal, in case logging.

sigterm - graceful shutdown in nodejs

a docker stop send sigterm signal, , that's standard 'close files , connections , stop program' signal sent *nix process. want handle sigint in same way (a ctrl-c sends this).

process.on('sigterm', function() {     winston.log('got sigterm, exiting');   process.exit(1); }); 

sigkill - not graceful kill

a docker kill or timeout on docker stop send sigkill. can't capture sigkill node.js kernels "kill , don't ask questions" last resort rid of process. capture logs kill need @ dockers logs, or other external monitoring/logging kills can come anywhere (for example kill -9 command or out of memory manager in kernel).

combining application , docker logs

you can combine docker logs application logs using docker logging driver matches winston transport if both logging central location. syslog, graylog(gelf) , fluentd open source log collectors , can used both.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -