From aadd148cc601a4b8d1f173d0f38ff705b88cecf0 Mon Sep 17 00:00:00 2001 From: "jokob.sk" Date: Sun, 9 Oct 2022 12:02:19 +1100 Subject: [PATCH] added JSON logging and updated readme --- .env | 8 +++++++- back/pialert.py | 5 ++++- docker-compose.yml | 6 ++++++ dockerfiles/README.md | 17 ++++++++++++++--- install/default | 3 +++ 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/.env b/.env index c75c843a..a7092470 100644 --- a/.env +++ b/.env @@ -1,10 +1,16 @@ -#GLOBAL +#GLOBAL PATH VARIABLES + APP_DATA_LOCATION=/path/to/docker_appdata APP_CONFIG_LOCATION=/path/to/docker_config LOGS_LOCATION=/path/to/docker_logs + +#ENVIRONMENT VARIABLES + TZ=Europe/Paris HOST_USER_ID=1000 HOST_USER_GID=1000 PORT=20211 +#DEVELOPMENT VARIABLES +DEV_LOCATION=/path/to/local/source/code \ No newline at end of file diff --git a/back/pialert.py b/back/pialert.py index 63631e41..9aa679af 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1629,7 +1629,10 @@ def send_webhook (_json, _html): "title_link": REPORT_DASHBOARD_URL, "text": payloadData }] - } + } + + # 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 if(WEBHOOK_URL.startswith('https://discord.com/api/webhooks/') and not WEBHOOK_URL.endswith("/slack")): diff --git a/docker-compose.yml b/docker-compose.yml index 3f878e97..b751f2b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,13 @@ services: volumes: - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config - ${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 + # 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: - TZ=${TZ} - PORT=${PORT} diff --git a/dockerfiles/README.md b/dockerfiles/README.md index f0804efe..b2cb5b28 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -67,7 +67,10 @@ services: volumes: - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config - ${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: - TZ=${TZ} - PORT=${PORT} @@ -78,14 +81,22 @@ services: `.env` file ```yaml -#GLOBAL +#GLOBAL PATH VARIABLES + APP_DATA_LOCATION=/path/to/docker_appdata APP_CONFIG_LOCATION=/path/to/docker_config LOGS_LOCATION=/path/to/docker_logs + +#ENVIRONMENT VARIABLES + TZ=Europe/Paris HOST_USER_ID=1000 HOST_USER_GID=1000 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` @@ -113,7 +124,7 @@ Courtesy of [pbek](https://github.com/pbek). The volume `pialert_db` is used by ## ☕ 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. Buy Me A Coffee diff --git a/install/default b/install/default index 983f9d5c..ea65dcc2 100644 --- a/install/default +++ b/install/default @@ -9,5 +9,8 @@ server { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_connect_timeout 75; + fastcgi_send_timeout 600; + fastcgi_read_timeout 600; } } \ No newline at end of file