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
Post a Comment