wbyoung / babel-plugin-transform-postcss

Babel PostCSS Transform
MIT License
55 stars 23 forks source link

Exit process cleanly on SIGINT, SIGTERM, and SIGUSR2 signals #75

Open carpie opened 6 years ago

carpie commented 6 years ago

Hi!

We are using this plugin for SSR workflow to take advantage of cssnext functionality. In our development workflow we run babel-node through nodemon. When nodemon restarts, it uses the SIGUSR2 signal to cause restarts in child processes. This plugin restarts and reports that it cannot create a new server because the existing one is already running and exists. (It seems to be because the socket didn't get cleaned up.) Also, when we exit nodemon, we have to interrupt twice to get the postcss-server process to end.

This PR represents the tweaks I came up with to use this plugin for our workflow. If it works for other work flows, it would be great if it could be merged!

The basic changes are to cause the postcss-server to exit on any of the handled signals and delegate the exit handler to clean up the server socket (since it's called in all cases).

Thanks!

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling db00bdcf1a438d83455da30440253ffe19dfd64e on carpie:master into ce92e0238b42011d709795191c7f322cb1cb046d on wbyoung:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling db00bdcf1a438d83455da30440253ffe19dfd64e on carpie:master into ce92e0238b42011d709795191c7f322cb1cb046d on wbyoung:master.