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: 幸い、現在は学習目的でのみこのマシンを使用しているため、問題はありません。このような重要な操作を行う前に、ユーザーに確認する質問を追加すべきかもしれません。

ドクターは、あなたのサイトが公開されていると想定しています。:wink:

ドクターが実行するほとんどのチェックは、動作するインストール環境でのみ行うことができます。

「いいね!」 3

それなら、Discourse Autopsy が必要ですね。

「いいね!」 9

pfaffman さん、これは実装されましたか?

Amazon SES が機能しない問題をデバッグしようとしており、discourse-doctor から得られた出力は以下の通りです:

==================== MAIL TEST ====================
確実なテストを行うには、http://www.mail-tester.com/ からメールアドレスを取得してください。
あるいは、単に自分自身にテストメールを送信してください。
メールテストのメールアドレスを入力してください(スキップするには 'n')[rich@xxx.xxx]:
rich@xxx.xxx にメールを送信中...
不明な短縮フラグ:'-w' in -w
'docker exec --help'を参照してください。

置換中:SMTP_PASSWORD
置換中:LETSENCRYPT_ACCOUNT_EMAIL
置換中:DEVELOPER_EMAILS
置換中:DISCOURSE_DB_PASSWORD
置換中:Sending mail to

==================== DONE! ====================
このファイルの公開バージョンを提供しますか?(Y/n)Y
不明な短縮フラグ:'-w' in -w
'docker exec --help'を参照してください。
このプログラムの出力は http://example.com/NTQyYTg2YzVjYzg1NTYx.txt で利用可能です。
URL を共有する前に、そのファイルを慎重に確認してください。

このスクリプトの出力は以下のコマンドで確認できます:
LESS=-Ri less /tmp/discourse-debug.txt

ただし、最初に以下の最初の 3 つのコマンドを必ず理解してください!!!

上記のコマンド('less'と呼ばれる)でファイルを表示する際に使用するコマンド:
q              -- 終了
/error<ENTER>  -- 単語 'error' を検索
n              -- 次の出現箇所を検索
g              -- ファイルの先頭へ移動
f              -- 次のページへ移動
b              -- 前のページへ移動
G              -- ファイルの末尾へ移動

メールは届きません。

そして、なぜか分かりません…

公開バージョンのファイルは作成されていないか、アクセスできません。URL にアクセスすると、単に「not-found」エラーが表示されるだけです。

パブリックリンクの以前の動作が壊れているようです。これはほとんど使われていないので、削除すべきでしょう。

SMTP テストは接続できるかを確認しますが、DNS チェックは行いません。

その docker exec エラーは、そこに何らかの問題があることを示唆しています。

送信アドレスに関する注記を追加することを検討します。これは依然として一般的な問題です。Discourse はフォーラムのサブドメインから送信しますが、メールサーバーはアペックスドメインを期待していることがよくあります。

メールの問題については、新しい Discourse インストールでのメールのトラブルシューティングを確認しましたか?

「いいね!」 2

コンソールに診断情報が提供されていないため、.txt ファイルでいくつかの詳細が得られることを期待していました。

また、txt ファイルの URL が https ではなく http である点にも気づきました(ただし、ここではそれが何も変えるわけではありません)。

ふむ、その Docker エラーは、SMTP テストが全く実行されていないことを意味しているかもしれません。

トラブルシューティングガイドを確認し、SMTP をテストする rake タスクを実行してください。

承知いたしました。ご返信ありがとうございます。

「いいね!」 1

./discourse-doctor スクリプトを実行した後、「このファイルを公開して提供しますか?」という質問に「はい」と回答したところ、メール認証情報(ログイン名、パスワード)が露呈していることが確認できました。

./discourse-doctor によって生成されたログやファイルを恒久的に削除するには、どこでどのようにすればよいでしょうか?

Hmm、申し訳ありません。何か変更があったのか、clean_up_log_file() が正しく機能しなくなったようですが、なぜかまではわかりません。

ファイル共有用の URL は実際に機能していますか?前回確認したときは動いていなかったと記憶しています。

rm /var/discourse/shared/standalone/public/*.txtを実行するか、実際のファイル名を確認して削除してください。

「いいね!」 1

URLから取得したファイル名(正確な名前)をルートディレクトリで探してみましたが、2つのファイルを削除しても、URLには引き続きログ情報がすべて表示されていました。最終的に、仮想マシンを終了させることにしました。とにかく、これは私にとって重要な経験でした。「認証情報を扱う際は本当に慎重になろう」

:wink:

「いいね!」 2

はい、私も同じ Docker エラーが発生し、メールが届きません。

../public/ の下ではなくなりました。var/discourse/shared/standalone/log/var-log/*.txt の下にあります。

将来変更された場合:
find -type f -name *.txt