opus
opus copied to clipboard
Ensure that flask application will not crash the docker container when it encounters a syntax error
Currently, when you save a python file on the server that causes a syntax error, it crashes the docker container, and you have to restart it. Ideally, it would continue trying to hot-reload the application without requiring you to restart the container.
server_1 | * Debugger PIN: 128-930-505
server_1 | 172.20.0.1 - - [17/Mar/2020 17:16:16] "GET / HTTP/1.1" 200 -
server_1 | 172.20.0.1 - - [17/Mar/2020 17:23:40] "GET / HTTP/1.1" 200 -
server_1 | * Detected change in '/server/run.py', reloading
server_1 | * Restarting with stat
server_1 | * Debugger is active!
server_1 | * Debugger PIN: 128-930-505
server_1 | * Detected change in '/server/run.py', reloading
server_1 | * Restarting with stat
server_1 | File "/server/run.py", line 6
server_1 | if __name__ == "__main__"::
server_1 | ^
server_1 | SyntaxError: invalid syntax
private-identity-server_server_1 exited with code 1
Not really sure if this is the solution we are looking for, but if you add restart: always
it will continuously try to restart the container, e.g.
version: '3'
services:
server:
image: openmined/pis:latest
build: ./server/
restart: always
Ah, that's great! I don't think it's a 100% ideal solution, as it does delay before restarting as opposed to doing it "on-save" of a file, but it's better than not having it in place at all. Thanks!
Hi!
I just pushed a PR proposing to use supervisor to target this issue. However, I wanted to document that if supervisor is not desired as a dependency for this case, it could still be possible to make a custom script like the official Docker documentation suggests: https://docs.docker.com/config/containers/multi-service_container/.