Skip to content

Commit

Permalink
Add no debug mode flag. (hedyorg#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro authored Sep 26, 2021
1 parent a045865 commit 31ae185
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ you can wrap the command in a loop to restart the server quickly).
(.env)$ while true; do env FLASK_ENV=development python app.py; sleep 1; done
```

If you prefer to avoid development mode (which might make the app reloads slower when opening Hedy in the browser), pass the `NO_DEBUG_MODE` environment variable.

```bash
(.env)$ env NO_DEBUG_MODE=1 python app.py
```

If you want to run the website locally, but would prefer to use Docker instead of installing python, you can build a container image and run it like so:

```bash
Expand Down
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def get_quiz(level_source, question_nr, attempt):

# Loop through the questions and check that the loop doesn't reach out of bounds
q_nr = int(question_nr)

if int(attempt) == 1:
questionStatus = 'start'

Expand Down Expand Up @@ -1104,7 +1104,7 @@ def on_server_start():
# Start the server on a developer machine. Flask is initialized in DEBUG mode, so it
# hot-reloads files. We also flip our own internal "debug mode" flag to True, so our
# own file loading routines also hot-reload.
utils.set_debug_mode(True)
utils.set_debug_mode(not os.getenv ('NO_DEBUG_MODE'))

# If we are running in a Python debugger, don't use flasks reload mode. It creates
# subprocesses which make debugging harder.
Expand All @@ -1115,4 +1115,4 @@ def on_server_start():
# Threaded option enables multiple instances for multiple user access support
app.run(threaded=True, debug=not is_in_debugger, port=config ['port'], host="0.0.0.0")

# See `Procfile` for how the server is started on Heroku.
# See `Procfile` for how the server is started on Heroku.
6 changes: 6 additions & 0 deletions doc/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ To set up the port of the app through an env variable (helpful to start multiple
PORT
```

To turn off development mode

```
NO_DEBUG_MODE
```

## Heroku Metadata

This app depends on some environment variables that require Heroku dyno metadata.
Expand Down

0 comments on commit 31ae185

Please sign in to comment.