elwerene / libreoffice-convert

MIT License
241 stars 94 forks source link

Each call of libre.convert() spawns a new process #98

Closed ezBeanie closed 1 year ago

ezBeanie commented 1 year ago

I am using package to convert pptx-files to pdf-files on a microservice inside a docker container based on node:16-slim. The service has an endpoint which receives a pptx-file and returns the converted pdf-file. Each time, libre.convert() is called, a new soffice process is spawned, it converts the pptx-file and it remains there as a "defunct" process.

How can I avoid this? Is there any way to tell the execFile method used inside your code to kill the process after it converted the file?

bradisson commented 1 year ago

Just run across the same issue.

If you ever figure it out please let me know.

Ine the mean time I'll look if I can find a solution too and let you know if I ever found anything.

ezBeanie commented 1 year ago

I found a solution, its a docker problem and has nothing to do directly with this npm package. Process Reaping can be enabled by using the flag --init (or setting init: true if you're using docker compose) Here's a resource to find out more about it: https://docs.docker.com/config/containers/multi-service_container/#:~:text=The%20%2D%2Dinit%20flag%20inserts,process%20lifecycle%20within%20your%20container.

@bradisson I hope this helps! If not, let me know.