nielsboecker / HoloRepository-Core

A system for transforming medical imaging studies into holograms, storing them in the cloud and providing them to other systems.
GNU Affero General Public License v3.0
7 stars 8 forks source link

PIPELINE: gunicorn entrypoint #73

Closed nielsboecker closed 5 years ago

nielsboecker commented 5 years ago

When you run the server through gunicorn, the __main__ doesn't run, so to fix that I followed the SO recommendation and put the initialisation to the top level (so it happens at import time)

However I am not sure if this is the right way to go. I haven't really verified it running in the gunicorn Docker container, as my computer is terribly slow. I think it may be a problem if/when we start gunicorn with multiple workers.

If we keep gunicorn workers at 1, as we have now, and start multiple processes in our own code, it should be fine? I noticed that when I just run Flask without gunicorn in development mode, it uses two processes, whereas when i run it with FLASK_ENV=production, it uses only 1. When I had two, they both tried to do the garbage collection file deletion. I added some error handling in #72 to solve that problem.

nielsboecker commented 5 years ago

@boonwj Not having this fix could also be related with the errors you mention in #67, as the initialisation from main method is not running when you use gunicorn.