宣布Discourse Doctor

Following the example from Discourse-doctor 👩‍⚕️, I’ve created discourse-doctor, now included in discourse_docker. If you run ./discourse-doctor, you’ll see something like:

DISCOURSE DOCTOR Tue Jul 24 08:50:32 UTC 2018
OS: Linux twonames 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux


Found containers/app.yml

==================== YML SETTINGS ====================
DISCOURSE_HOSTNAME=twonames.ltcmp.net
SMTP_ADDRESS=mail.domain.com
DEVELOPER_EMAILS=REDACTED 
SMTP_PASSWORD=REDACTED 
SMTP_PORT=587
SMTP_USER_NAME=postmaster@cakeme.ltcmp.net
LETSENCRYPT_ACCOUNT_EMAIL=REDACTED 

==================== DOCKER INFO ====================
DOCKER VERSION: Docker version 18.05.0-ce, build f150324

DOCKER PROCESSES (docker ps -a)

CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                    PORTS                                      NAMES
c75f29870c3b        local_discourse/app           "/sbin/boot"             5 days ago          Up 5 days                 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   app
adc8de3e5156        discourse/base:2.0.20180613   "/bin/bash -c 'cd /p…"   5 days ago          Exited (137) 5 days ago                                              quirky_zhukovsky


Discourse container app is running


==================== PLUGINS ====================
          - git clone https://github.com/discourse/docker_manager.git

No non-official plugins detected.

See https://github.com/discourse/discourse/blob/master/lib/plugin/metadata.rb for the official list.

========================================
Discourse version at twonames.ltcmp.net: Discourse 2.1.0.beta2 
Discourse version at localhost: Discourse 2.1.0.beta2 


==================== MEMORY INFORMATION ====================
OS: Linux
RAM (MB): 1016

              total        used        free      shared  buff/cache   available
Mem:            992         577          69          28         345         184
Swap:          2047         301        1746

==================== DISK SPACE CHECK ====================
---------- OS Disk Space ----------
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        25G   12G   13G  48% /

---------- Container Disk Space ----------
Filesystem      Size  Used Avail Use% Mounted on
overlay          25G   12G   13G  48% /
/dev/vda1        25G   12G   13G  48% /shared
/dev/vda1        25G   12G   13G  48% /var/log

==================== DISK INFORMATION ====================
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 603625F3-7AE2-40CB-B05E-0BD7EA2D57E4

Device      Start      End  Sectors  Size Type
/dev/vda1  227328 52428766 52201439 24.9G Linux filesystem
/dev/vda14   2048    10239     8192    4M BIOS boot
/dev/vda15  10240   227327   217088  106M Microsoft basic data

Partition table entries are not in disk order.

==================== END DISK INFORMATION ====================

==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Mail test skipped.

==================== DONE! ====================
The output of this program may be available at http://twonames.ltcmp.net/YzUwYjE5MzlmN2EyZTAz.txt
You should inspect that file carefully before sharing the URL.

You can examine the output of this script with 
LESS=-Ri less /tmp/discourse-debug.txt

BUT FIRST, make sure that you know the first three commands below!!!

Commands to know when viewing the file with the above command (called 'less'): 
q              -- quit
/error<ENTER>  -- search for the word 'error'
n              -- search for the next occurrence
g              -- go to the beginning of the file
f              -- go forward a page
b              -- go back a page
G              -- go to the end of the file

If the container isn’t running, discourse-doctor will attempt a rebuild and add the output of the build to the log file, which, if the container cranks up enough to have nginx, will be accessible via a URL, saving folks the trouble of uploading to something like pastebin. Passwords and email addresses are redacted by the script. Domain names are left intact, as there is rarely reason to hide your site given that it’s on the Internet already.

Right now, you have to know that discourse-doctor exists, but in the next few days, I’ll submit a PR to have launcher and discourse-setup recommend it.

Next Steps

  • have launcher recommend discourse-doctor
  • have discourse-setup recommend discourse-doctor
  • make the mail test rake task do some actual testing rather than just sending , like . . .
    – test connectivity to the port
    – does password work
    – SPF, DKIM, dmarc
    – tell them they can’t use gmail (should also add this to discourse-setup )
    – tell them what email address is in the from: line
  • have launcher disallow mixed case domain names
  • if rebuild rails, re-start old container – this is both trivial and huge, as I think few people know that if the rebulid fails you can just restart the container.
  • (tentative) do some kind of yml linting. It looks like launcher does some kind of yaml parsing in host_run . But part of me says “You break it. You bought it.”
  • consider handling files other than app.yml
  • have the doctor comment out plugins not from discourse github organization

If you have comments or suggestions, please let me know!

36 个赞

刚在一台站点已停止运行的机器上运行了此操作。本以为只会执行一组简单的检查并报告结果,没想到会触发重建、下载并启动站点。:grinning_face_with_smiling_eyes: 幸运的是,我目前只是用这台机器进行学习,所以没有造成任何损害。或许在继续之前,应该先询问用户是否希望执行如此重大的操作。

Doctor 假设您希望您的网站上线。:wink:

它执行的许多检查只能在已正常安装的站点上进行。

3 个赞

那我猜我需要 Discourse Autopsy。

9 个赞

@pfaffman,这个功能后来添加了吗?

我正在尝试调试 Amazon SES 无法工作的问题,这是 discourse-doctor 的输出:

==================== 邮件测试 ====================
要进行可靠的测试,请从 http://www.mail-tester.com/ 获取一个地址
或者只需发送一封测试邮件给自己。
邮件测试的电子邮件地址?(输入 'n' 跳过)[rich@xxx.xxx]:
正在向 rich@xxx.xxx 发送邮件...
未知的简写标志:'w' 在 -w 中
请查看 'docker exec --help'。

正在替换:SMTP_PASSWORD
正在替换:LETSENCRYPT_ACCOUNT_EMAIL
正在替换:DEVELOPER_EMAILS
正在替换:DISCOURSE_DB_PASSWORD
正在替换:正在发送邮件到

==================== 完成!====================
您是否希望提供此文件的公开版本?(Y/n)Y
未知的简写标志:'w' 在 -w 中
请查看 'docker exec --help'。
该程序的输出可能位于 http://example.com/NTQyYTg2YzVjYzg1NTYx.txt
在分享该 URL 之前,请仔细检查该文件。

您可以使用以下命令查看此脚本的输出:
LESS=-Ri less /tmp/discourse-debug.txt

但首先,请确保您了解以下前三个命令!!!

使用上述命令(称为 'less')查看文件时需要知道的命令:
q              -- 退出
/error<ENTER>  -- 搜索单词 'error'
n              -- 搜索下一个匹配项
g              -- 跳转到文件开头
f              -- 向前翻页
b              -- 向后翻页
G              -- 跳转到文件末尾

没有收到任何邮件。

我也不知道原因……

该文件的公开版本要么未创建,要么无法访问,因为访问该 URL 时我只会收到“未找到”错误。

看来公共链接的旧工作方式已失效。它几乎从未被使用,应该删除。

SMTP 测试会检查是否能建立连接,但不会进行 DNS 检查。

那个 docker exec 错误表明那里存在问题。

我会考虑添加一条关于发件地址的说明。这仍然是一个常见问题。Discourse 从论坛子域名发送邮件,而邮件服务器通常期望使用根域名。

关于您的邮件问题,您是否查阅过 在新安装的 Discourse 上排查邮件问题

2 个赞

由于控制台未提供任何诊断信息,我原本希望 .txt 文件能提供一些详细信息。

我还注意到该 txt 文件的 URL 使用的是 http 而不是 https(不过这在此处并无影响)。

嗯。也许那个 Docker 错误意味着它根本不再运行 SMTP 测试了。

你应该查看故障排除指南,并运行测试 SMTP 的 rake 任务。

好的,谢谢回复。

1 个赞

运行 ./discourse-doctor 脚本后,我在回答“是否要提供此文件的公开版本?”时选择了“是”,结果发现邮件凭据(登录名、密码)已泄露。

请问在哪里以及如何永久删除由 ./discourse-doctor 生成的日志/文件?

嗯,对此很抱歉。我想可能是某些变化导致 clean_up_log_file() 无法再正常工作了,不过我不确定具体原因。

分享文件的 URL 还能用吗?我很有把握上次检查时它已经失效了。

你可以执行 rm /var/discourse/shared/standalone/public/*.txt。或者查看该目录以获取文件的实际名称,然后将其删除。

1 个赞

我尝试在根目录中查找该文件的准确名称(名称取自 URL)。我删除了两个文件,但 URL 仍然显示了完整的日志信息。最后,我决定终止虚拟机。无论如何,这对我来说是一次重要的经验教训:“在使用凭据时务必格外小心”。

:wink:

2 个赞

是的,我也遇到同样的 Docker 错误,并且没有收到邮件。

它不再位于 ../public/ 下。位于 var/discourse/shared/standalone/log/var-log/*.txt

如果将来发生更改:
find -type f -name *.txt