CodeAbbey/abbey2

Python in docker env should restart after error

RodionGork opened this issue · 1 comments

In local environment we are supposed to use docker as explained in the readme (and video).

However, currently it works so, that if python code in server breaks for some reason, the whole thing stops.

Reproducing:

Start docker env as explained, check the main page at http://localhost:5000/ - then in the main.py change the line

app.register_blueprint(users_ctl)

so that it has user_ctl or users_ktl - e.g. some non-existent identifier. Try to reload the main page. It should result in the stacktrace in console, docker container stopped and page not responding:

 * Detected change in '/code/main.py', reloading
 * Restarting with stat
Traceback (most recent call last):
  File "/code/main.py", line 17, in <module>
    app.register_blueprint(user_ctl)
NameError: name 'user_ctl' is not defined

What we want

Let's have some surrounding loop in the shell script, so that if server fails, the message like "press enter
to restart" is shown after stacktrace (and on pressing the key) server attempts restart.

It would be also good if the server stops gracefully on pressing Ctrl-C (thus we can stop the container
without docker stop ...)

How to

Here is a file like docker/local/run.sh which is executed in the container to run the server, so changes
should be made in it, I think. Image should be rebuilt then and container restarted for testing.

(in development it may be easier to docker exec ... bash into container to try changing the file on the fly)

Works as intended (including stopping by Ctrl-C) after 4155d3a