appy-one / acebase

A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
MIT License
492 stars 27 forks source link

Proper way to shut down on SIGINT #89

Closed advplyr closed 2 years ago

advplyr commented 2 years ago

Just trying this out and when CTRL+C to exit out of a node express server acebase is catching the SIGINT but not calling process.exit().

This is resulting in the express server remaining open. I noticed the process.exit() function was commented out a while back, probably for good reason but if left in it would properly exit in my case.

https://github.com/appy-one/acebase/blob/9c72e433eec9a9d44777e77c23cb9f2185c7b9e7/src/ts/ipc/index.ts#L122-L126

I'm on Windows 10, Node v16. I'm not sure if I catch the SIGINT myself and process.exit if that will leave anything open in acebase.

advplyr commented 2 years ago

I have a fine solution now by registering process.on('SIGINT') after instantiating AceBase and calling process.exit myself.

Now I understand why this is better then AceBase calling process.exit because it allows me to clean up what I need to before exiting. It looked like the close() method wasn't implemented yet when I skimmed the code, but this solution works for me anyway.