postlight / lux

Build scalable, Node.js-powered REST JSON APIs with almost no code.
https://lux.postlight.com
MIT License
570 stars 60 forks source link

fix: gracefully shutdown workers instead of waiting for the timeout to pass (fixes #702) #703

Closed nickschot closed 7 years ago

nickschot commented 7 years ago

Fixes #702

I've reordered the code a bit to make sure the listeners are attached before they can happen.

codecov[bot] commented 7 years ago

Codecov Report

Merging #703 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #703   +/-   ##
=======================================
  Coverage   92.44%   92.44%           
=======================================
  Files         180      180           
  Lines        2012     2012           
=======================================
  Hits         1860     1860           
  Misses        152      152

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update df96fd6...4a6ae9f. Read the comment docs.

nickschot commented 7 years ago

After some more reading this might not fully remove the (old) worker. Disconnect seems to close only the IPC channel.

We could just call kill on the worker after the disconnect went through as "reload" is only used in development anyway (or keep the timeout running in the background though that's less pretty I think).