RuntimeTools / appmetrics-dash

A data visualizer that uses " Node Application Metrics" (appmetrics) to monitor and display Node.js application data as a html web application.
Other
452 stars 55 forks source link

Usage With Nodemon #75

Open jesseweed opened 7 years ago

jesseweed commented 7 years ago

I've notice when used a conjunction with nodemon, a new heap snapshot is written to disk every time the server restarts.

Obviously this would be less of an issue in production, but any thoughts on how to create less file pollution when running in develop mode?

Perhaps dumping the snapshots into some kind of log folder instead of the root, or possibly even an option to disable creating the file altogether?

hhellyer commented 7 years ago

This looks like an interaction with the signal handler used for creating a heapdump. I can reproduce it without appmetrics by running with the heapdump module which appmetrics-dash includes: > nodemon -r heapdump simplehttp.js and typing "rs" - this creates a heap dump. I'm assuming nodemon uses a signal to restart the process it's monitoring.

(simplehttp.js just listens for http connections to keep the node process alive.)

Running with an env var which disables signal handling in heap dump seems to improve things for me: > env NODE_HEAPDUMP_OPTIONS=nosignal nodemon -r heapdump simplehttp.js (This works when using appmetrics-dash too.)

I think there's a bit of a clash of signal handlers here. Two modules are using them for different purposes. Does that help at all? I'll investigate a bit more to see if there's anything useful we can do here.

tobespc commented 6 years ago

@hhellyer I'm hitting this now

Aerex commented 6 years ago

I would like to my piece as I am running into the same problem. @hhellyer is correct that there is a signal handling conflict. Nodemon uses SIGUSR2 to handle restarting the app and Appmetrics which uses heapdump as a dependencies uses SIGUSR2 to forcefully create a heapdump snapshot. I don't think in Node you can handle two signals at the same time

hhellyer commented 6 years ago

@Aerex - Does setting NODE_HEAPDUMP_OPTIONS (see above) fix the problem for you?

Aerex commented 6 years ago

@hhellyer It does fix the problem. Thanks for your insight. Is there another way where appmetrics doesn't use this signal for that will interfere with nodemon. I don't think setting this environment variable should be the permanent solution.

jkingoliver commented 6 years ago

We would like our node users to be able to use appmetrics and nodemon both and recommending that they set an env var to enable functionality doesn't seem like a good solution, I agree with @Aerex .

@hhellyer and @tobespc Can we re-open this discussion and try to find a different solution? My team is considering disabling appmetrics for local development in our tooling in order to enable hot reload with nodemon, which is an unfortunate choice.

jkingoliver commented 5 years ago

@hhellyer and @tobespc Following up on this issue-- is finding a better solution to the signal handling problem on your radar for 2019?