digidem / mapeo-map-server

Offline map style and tile server
MIT License
5 stars 2 forks source link

fix: Fix v8 error with graceful onClose cleanup #53

Closed gmaclennan closed 2 years ago

gmaclennan commented 2 years ago

Seems like the cause of the v8 error we were getting (https://github.com/WiseLibs/better-sqlite3/issues/842) might have been caused by terminating the worker threads without first closing the DB instance. This PR attempts to fix that by doing a graceful shutdown of workers (it waits for them to finish) before closing the server completely. This PR also adds the minThreads: 1 option to Piscina, since otherwise I think Piscina opens a worker thread for every CPU available on startup. This minimizes the initial overhead of thread creation.