From 98fb02282b9e6ae668e9462ab02a7e99d023959b Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 18 Jul 2023 08:06:32 +1000 Subject: [PATCH] Debug tips --- docs/DEBUG_TIPS.md | 32 ++++++++++++++++++-------------- pialert/helper.py | 4 ++++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/DEBUG_TIPS.md b/docs/DEBUG_TIPS.md index 32793931..47305d59 100755 --- a/docs/DEBUG_TIPS.md +++ b/docs/DEBUG_TIPS.md @@ -1,23 +1,17 @@ -## More Logging +# Debugging and troubleshooting + +Please follow tips 1 - 4 to get a more detailed error. + +## 1. More Logging 📃 When debugging an issue always set the highest log level: `LOG_LEVEL='debug'` -## Check the _dev image and open issues +## 2. Surfacing errors when container restarts 🔁 -If possible, check if your issue got fixed in the `_dev` image before opening a new issue. The container is: - -`jokobsk/pi.alert_dev:latest` - -> ⚠ Please backup your DB and config beforehand! - -Please also search [open issues](https://github.com/jokob-sk/Pi.Alert/issues). - -## Surfacing errors when container restarts - -Start the container via the terminal with a command similar to this one: +Start the container via the **terminal** with a command similar to this one: ```bash docker run --rm --network=host \ @@ -31,7 +25,17 @@ docker run --rm --network=host \ > ⚠ Please note, don't use the `-d` parameter so you see the error when the container crashes. Use this error in your issue description. -## Disable restart behavior +## 3. Check the _dev image and open issues ❓ + +If possible, check if your issue got fixed in the `_dev` image before opening a new issue. The container is: + +`jokobsk/pi.alert_dev:latest` + +> ⚠ Please backup your DB and config beforehand! + +Please also search [open issues](https://github.com/jokob-sk/Pi.Alert/issues). + +## 4. Disable restart behavior 🛑 To prevent a Docker container from automatically restarting in a Docker Compose file, specify the restart policy as `no`: diff --git a/pialert/helper.py b/pialert/helper.py index 7aa654d6..2c9fe5ae 100755 --- a/pialert/helper.py +++ b/pialert/helper.py @@ -30,6 +30,8 @@ def timeNowTZ(): def updateState(db, newState): # ?? Why is the state written to the DB? + # The state is written to the DB so the front-end can use the value to display the current state in the header of the app + # The Parameters DB table is used to communicate with the front end. #sql = db.sql @@ -63,6 +65,8 @@ def checkPermissionsOK(): dbR_access = (os.access(fullDbPath, os.R_OK)) dbW_access = (os.access(fullDbPath, os.W_OK)) + mylog('none', ['\n']) + mylog('none', ['The container restarted (started). If this is unexpected check bit.ly/PiAlertDebug for troubleshooting tips.']) mylog('none', ['\n']) mylog('none', ['Permissions check (All should be True)']) mylog('none', ['------------------------------------------------'])