zrrrzzt / docker-unoconv-webservice

Dockerfile to run unoconv as a webservice
MIT License
96 stars 35 forks source link

Webservice unavailable after restarting container #3

Closed jhmaddox closed 8 years ago

jhmaddox commented 8 years ago

Thanks for your work on the unoconv webservice and for providing this easy to use Docker image! I ran into one problem: the unoconv webservice stops working after restarting the container. After a restart, all requests fail without a response.

To replicate:

git clone git@github.com:zrrrzzt/docker-unoconv-webservice.git docker build -t unoconvtest docker-unoconv-webservice docker run -d -p 3000:3000 unoconvtest curl localhost:3000 docker stop <id> docker start <id> curl localhost:3000

The first curl will print {"statusCode":404,"error":"Not Found"} (as expected). The second curl will print curl: (56) Recv failure: Connection reset by peer

This isn't ideal because it causes the image to fail silently in typical workflows for docker-compose, kubernetes, etc.

My guess is that /usr/bin/unoconv doesn't exit gracefully on SIGTERM or SIGKILL, so when the container restarts, /usr/bin/unoconv --listener hangs and node standalone.js is never executed. One potential fix might be to run the two commands in parallel instead of as an &&-list.

In other words,

ENTRYPOINT /usr/bin/unoconv --listener --server=0.0.0.0 --port=2002 && node standalone.js

would become

ENTRYPOINT /usr/bin/unoconv --listener --server=0.0.0.0 --port=2002 & node standalone.js

Thanks!

zrrrzzt commented 8 years ago

Thank you for your interest in this project and the solution @jhmaddox :-) I changed the entrypoint to your specs and this time everything worked after stop and start.

Updated Dockerfile is pushed to GitHub and the prebuild image is available from https://hub.docker.com/r/zrrrzzt/docker-unoconv-webservice