I'm curious whether folks are interested in revisiting some of the design decisions.
For one it'd be interesting if stoppable() could return the stop() function, rather than assigning it to the server value. Calling code could still do server.stop = stoppable(server). Personally I don't find the chaining argument convincing.
It'd also be neat if stop() would return a promise, rather than taking a callback. It wouldn't match the server.close() API but in these glorious days of async / await I think returning a promise would be more usable.
Once stop() no longer takes a callback it'd be possible to pass grace directly.
These last two changes combined make it possible to use stoppable with https://www.npmjs.com/package/@digicat/termination-manager (which, full disclaimer, I wrote). That library can vary the grace period based on whether the process is crashing or merely terminating, which doesn't work with stoppable as-is.
If folks disagree I'm happy to publish a fork elsewhere but I figured I'd ask first. These nits aside stoppable is the nicest library I've found for stopping servers 🥇
Thanks for reading this far!
I'm curious whether folks are interested in revisiting some of the design decisions.
For one it'd be interesting if
stoppable()could return thestop()function, rather than assigning it to theservervalue. Calling code could still doserver.stop = stoppable(server). Personally I don't find the chaining argument convincing.It'd also be neat if
stop()would return a promise, rather than taking a callback. It wouldn't match theserver.close()API but in these glorious days ofasync / awaitI think returning a promise would be more usable.Once
stop()no longer takes a callback it'd be possible to passgracedirectly.These last two changes combined make it possible to use
stoppablewith https://www.npmjs.com/package/@digicat/termination-manager (which, full disclaimer, I wrote). That library can vary thegraceperiod based on whether the process is crashing or merely terminating, which doesn't work withstoppableas-is.If folks disagree I'm happy to publish a fork elsewhere but I figured I'd ask first. These nits aside
stoppableis the nicest library I've found for stopping servers 🥇Thanks for reading this far!