My application is catching SIGINT and logs some shutdown messages which are then piped through the Bunyan CLI. Bunyan CLI is also shutting down immediately because of SIGINT, and so my app ends up without anything to write to, and my logs are lost.
Should Bunyan CLI really care about SIGINT at all? Why not let it gracefully close when the input application closes the socket? When I change:
process.on('SIGINT', function () { cleanupAndExit(1, 'SIGINT'); });
to
process.on('SIGINT', () => {});
the whole problem goes away. Bunyan CLI still shuts down, but lets logging finish first.
Now maybe there are other approaches to this issue, but in any case, it definitely is an issue for me.
We are having the same problem. We have an application that logs things after a SIGINT and its all lost through the cli. This is pretty bad for us since those logs are very important.
Can you guys try [email protected] (explicitly not marked as "latest" so it isn't the default version installed)? It includes: https://github.com/trentm/node-bunyan/commit/0d62f8a890341c1bf99b3a298af068853fc4f82a
I installed 2.0.2 and the problem is the same. Just to clarify the issue, I have a SIGINT handle on my node server to gracefully shutdown, and there are logs associated with that. If I use the cli node service.js | bunyan and then call ctrl-c then the cli just shuts down and no logs in stdout show up. I just figured out that If I don't pipe anything into buynan (just plain old node service.js) then my logs do show up in stdout. This might not be much of an major issue in production assuming i'm not viewing the logs actively during a shutdown or use the cli to pipe it somewhere else but its problematic in development
While I probably should be running my logs like so:
node index.js > /tmp/log
tail -f /tmp/log | bunyan
It'd be awfully convenient if the one-liner node index.js | bunyan worked, especially for debugging.
+1 for this issue.
I too am having the same issue, and have tested versions 1.8 and 2.0. I frequently using the one-liner node source/index.js | bunyan for dev, and use process.on("SIGINT", ...) to do cleanup (some of which requires logging).
Having some way to _configure_ bunyan so that it does not use a SIGINT listener would be super handy in such a case.
Most helpful comment
While I probably should be running my logs like so:
It'd be awfully convenient if the one-liner
node index.js | bunyanworked, especially for debugging.+1 for this issue.