added JSON logging and updated readme

This commit is contained in:
jokob.sk
2022-10-09 12:02:19 +11:00
parent 4e8401ab7e
commit aadd148cc6
5 changed files with 34 additions and 5 deletions

8
.env
View File

@@ -1,10 +1,16 @@
#GLOBAL #GLOBAL PATH VARIABLES
APP_DATA_LOCATION=/path/to/docker_appdata APP_DATA_LOCATION=/path/to/docker_appdata
APP_CONFIG_LOCATION=/path/to/docker_config APP_CONFIG_LOCATION=/path/to/docker_config
LOGS_LOCATION=/path/to/docker_logs LOGS_LOCATION=/path/to/docker_logs
#ENVIRONMENT VARIABLES
TZ=Europe/Paris TZ=Europe/Paris
HOST_USER_ID=1000 HOST_USER_ID=1000
HOST_USER_GID=1000 HOST_USER_GID=1000
PORT=20211 PORT=20211
#DEVELOPMENT VARIABLES
DEV_LOCATION=/path/to/local/source/code

View File

@@ -1631,6 +1631,9 @@ def send_webhook (_json, _html):
}] }]
} }
# DEBUG - Write the json payload into a log file for debugging
write_file (LOG_PATH + '/webhook_payload.json', str(_json_payload))
# Using the Slack-Compatible Webhook endpoint for Discord so that the same payload can be used for both # Using the Slack-Compatible Webhook endpoint for Discord so that the same payload can be used for both
if(WEBHOOK_URL.startswith('https://discord.com/api/webhooks/') and not WEBHOOK_URL.endswith("/slack")): if(WEBHOOK_URL.startswith('https://discord.com/api/webhooks/') and not WEBHOOK_URL.endswith("/slack")):
_WEBHOOK_URL = f"{WEBHOOK_URL}/slack" _WEBHOOK_URL = f"{WEBHOOK_URL}/slack"

View File

@@ -8,7 +8,13 @@ services:
volumes: volumes:
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
# (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt
- ${APP_DATA_LOCATION}/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode
# (optional) useful for debugging if you have issues setting up the container
- ${LOGS_LOCATION}:/home/pi/pialert/log - ${LOGS_LOCATION}:/home/pi/pialert/log
# comment out below 2 lines, they are only for development purposes
- ${DEV_LOCATION}/back/pialert.py:/home/pi/pialert/back/pialert.py
- ${DEV_LOCATION}/front:/home/pi/pialert/front
environment: environment:
- TZ=${TZ} - TZ=${TZ}
- PORT=${PORT} - PORT=${PORT}

View File

@@ -67,7 +67,10 @@ services:
volumes: volumes:
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
- ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
- ${LOGS_LOCATION}/:/home/pi/pialert/log # (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt
- ${APP_DATA_LOCATION}/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode
# (optional) useful for debugging if you have issues setting up the container
- ${LOGS_LOCATION}:/home/pi/pialert/log
environment: environment:
- TZ=${TZ} - TZ=${TZ}
- PORT=${PORT} - PORT=${PORT}
@@ -78,14 +81,22 @@ services:
`.env` file `.env` file
```yaml ```yaml
#GLOBAL #GLOBAL PATH VARIABLES
APP_DATA_LOCATION=/path/to/docker_appdata APP_DATA_LOCATION=/path/to/docker_appdata
APP_CONFIG_LOCATION=/path/to/docker_config APP_CONFIG_LOCATION=/path/to/docker_config
LOGS_LOCATION=/path/to/docker_logs LOGS_LOCATION=/path/to/docker_logs
#ENVIRONMENT VARIABLES
TZ=Europe/Paris TZ=Europe/Paris
HOST_USER_ID=1000 HOST_USER_ID=1000
HOST_USER_GID=1000 HOST_USER_GID=1000
PORT=20211 PORT=20211
#DEVELOPMENT VARIABLES
DEV_LOCATION=/path/to/local/source/code
``` ```
To run the container execute: `sudo docker-compose --env-file /path/to/.env up` To run the container execute: `sudo docker-compose --env-file /path/to/.env up`
@@ -113,7 +124,7 @@ Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by
## ☕ Support ## ☕ Support
> Disclaimer: This is my second container and I might have used unconventional hacks so if anyone is more experienced, feel free to fork/create pull requests. Also, please only donate if you don't have any debt yourself. Support yourself first, then others. > Disclaimer: Please only donate if you don't have any debt yourself. Support yourself first, then others.
<a href="https://www.buymeacoffee.com/jokobsk" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 30px !important;width: 117px !important;" width="150px" ></a> <a href="https://www.buymeacoffee.com/jokobsk" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 30px !important;width: 117px !important;" width="150px" ></a>

View File

@@ -9,5 +9,8 @@ server {
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_connect_timeout 75;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
} }
} }