appmetrics-dash icon indicating copy to clipboard operation
appmetrics-dash copied to clipboard

Usage With Nodemon

Open jesseweed opened this issue 7 years ago • 7 comments

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?

jesseweed avatar May 16 '17 20:05 jesseweed

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.

hhellyer avatar May 17 '17 09:05 hhellyer

@hhellyer I'm hitting this now

tobespc avatar Jan 10 '18 21:01 tobespc

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

Aerex avatar Jan 31 '18 23:01 Aerex

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

hhellyer avatar Feb 01 '18 09:02 hhellyer

@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.

Aerex avatar Mar 05 '18 21:03 Aerex

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 avatar Mar 05 '18 21:03 jkingoliver

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

jkingoliver avatar Jan 22 '19 17:01 jkingoliver