babel-plugin-transform-postcss icon indicating copy to clipboard operation
babel-plugin-transform-postcss copied to clipboard

#50 - cleanly exit postcss-server when signaled by client process

Open MaxMotovilov opened this issue 4 years ago • 5 comments

SIGTERM handler prevented process from ending - it has to stop the server explicitly in order for the rest of the cleanup logic to work as designed.

MaxMotovilov avatar Aug 30 '19 13:08 MaxMotovilov

Coverage Status

Coverage remained the same at 100.0% when pulling f7011a394846061ccbd3a723a792e049baaa9430 on MaxMotovilov:master into 55c18cea6a8a0d6c904e20f7634f269e7c8da7f0 on wbyoung:master.

coveralls avatar Aug 30 '19 13:08 coveralls

Ok, this looks good to me. Any docs that point to this being a requirement or is this just anecdotal? Can you find any docs for this requirement?

Also, I'm not actually using this personally any more, so to merge with confidence, I'd love it if we could find someone else to verify that this works and doesn't break any use cases.

Finally, in order to merge, the CI build will need to pass.

Thanks for contributing!

wbyoung avatar Aug 30 '19 15:08 wbyoung

Please review; see http://man7.org/linux/man-pages/man7/signal.7.html for the official documentation on Unix signals.

If you do accept the PR, could you publish the package to npmjs? As things are now, the published version is already behind the master branch.

MaxMotovilov avatar Aug 30 '19 19:08 MaxMotovilov

Right, I know how signals work. I was curious about needing to stop the server. I'm surprised that this wouldn't have been something that I ran into originally. Any other instances you know of that are similar to this?

wbyoung avatar Aug 30 '19 23:08 wbyoung

Stopping the server executes the listener in your code that removes all signal handlers and then event queue drains and node exits. Calling process.exit() from the signal handler works too (that's what I tried first) but it executes the code removing socket file 2nd time around and throws an error. Calling server.close() was simply the path of least resistance.

MaxMotovilov avatar Aug 30 '19 23:08 MaxMotovilov