diff --git a/roles/docker-discourse/Debug.md b/roles/docker-discourse/Debug.md new file mode 100644 index 00000000..c0713f9b --- /dev/null +++ b/roles/docker-discourse/Debug.md @@ -0,0 +1,106 @@ +## Discourse Debugging Guide for Docker Role + +This document explains how to locate and use key log file paths on both the host and inside the container for a Docker-based Discourse installation deployed via the `docker-discourse` role. + +### 1. Host Paths + +Discourse log files are stored in the Docker volume named `discourse_data`. On the host, you can find them at: + +* **Rails Production Log**: + + ```bash + cat /var/lib/docker/volumes/discourse_data/_data/log/rails/production.log | grep -i mail + ``` + + Filters for email-related entries: + + * **Queued emails**: `Email::Sender: queued mail to user@example.com` + * **Errors**: e.g. `Net::SMTPAuthenticationError`, `SMTPConnectionError` + +* **Sidekiq Log**: + + ```bash + cat /var/lib/docker/volumes/discourse_data/_data/log/sidekiq.log | grep -i mail + ``` + + Shows asynchronous mail job executions, retries, and failures. + +### 2. Inside the Container + +To inspect logs within the container, enter it: + +```bash +cd /var/discourse +./launcher enter app +``` + +Logs are mounted under `/var/log` inside the container: + +* **Rails Production Log**: + + ```bash + tail -n 200 /var/log/rails/production.log | grep -i mail + ``` + + * **Info**: `I, [timestamp] INFO -- : Email::Sender: queued mail to ...` + * **Error**: `E, [timestamp] ERROR -- : Net::SMTPSyntaxError ...` + +* **Sidekiq Log**: + + ```bash + tail -n 200 /var/log/sidekiq.log | grep -i mail + ``` + + * **Execution**: `Mail::MessageJob JID-...` + * **Retries/Exceptions** on delivery failure. + +### 3. Live Streaming Logs + +For real-time monitoring while reproducing an issue: + +```bash +# On host: + +tail -f \ + /var/lib/docker/volumes/discourse_data/_data/log/rails/production.log \ + /var/lib/docker/volumes/discourse_data/_data/log/sidekiq.log | grep -i mail + +# Or inside container: +tail -f /var/log/rails/production.log /var/log/sidekiq.log | grep -i mail +``` + +### 4. Enabling Verbose Email Debugging + +For detailed SMTP conversation logging: + +```bash +# Inside container +rails c +> Discourse.debug_email = true +``` + +Send a test email: + +```bash +rails c +> UserMailer.test_email("you@example.com").deliver_now +``` + +Then check logs for the full SMTP handshake details. + +### 5. Flushing Redis Cache + +After configuration changes, clear Redis to remove stale session or cached data: + +```bash +# Inside container +rails r "Redis.new.flushall" +``` + +### 6. Sidekiq Web UI + +In the Admin UI under **Plugins → Sidekiq**, monitor queues, retries, and failed jobs for additional context. + +--- + +Use this guide to quickly locate and interpret Discourse logs on both host and container, enabling efficient debugging of email delivery and background job issues in a Docker deployment managed by the `docker-discourse` role. diff --git a/roles/docker-discourse/templates/discourse_application.yml.j2 b/roles/docker-discourse/templates/discourse_application.yml.j2 index aad39d9c..bf8fa903 100644 --- a/roles/docker-discourse/templates/discourse_application.yml.j2 +++ b/roles/docker-discourse/templates/discourse_application.yml.j2 @@ -62,7 +62,8 @@ env: DISCOURSE_SMTP_PORT: {{ system_email.port }} DISCOURSE_SMTP_USER_NAME: {{ users['no-reply'].email }} DISCOURSE_SMTP_PASSWORD: {{ users['no-reply'].mailu_token }} - DISCOURSE_SMTP_ENABLE_START_TLS: {{ system_email.start_tls | upper }} + DISCOURSE_SMTP_ENABLE_START_TLS: {{ system_email.start_tls }} + DISCOURSE_SMTP_FORCE_TLS: {{ system_email.tls }} DISCOURSE_SMTP_DOMAIN: {{ system_email.domain }} DISCOURSE_NOTIFICATION_EMAIL: {{ users['no-reply'].email }}