zorrobyte
(Ross Fisher)
2018 年 6 月 27 日午後 3:19
1
Greetings,
I can’t post in the Sysadmin category.
I can configure an external DB using:
DISCOURSE_DB_USERNAME
DISCOURSE_DB_PASSWORD
DISCOURSE_DB_HOST
DISCOURSE_DB_NAME
But I couldn’t find:
DISCOURSE_DB_PORT (External PostgreSQL Port)
DISCOURSE_REDIS_HOST
DISCOURSE_REDIS_USERNAME
DISCOURSE_REDIS_PASSWORD
DISCOURSE_REDIS_NAME (which database, 0,1,2,3, etc)
I’m an engineer at Compose/IBM and I’m attempting to setup Discourse using our production-ready, replicated databases. I’d like to run a web_only instance with external Redis & PostgreSQL
I also couldn’t find configuration parameters for failover support:
We supply two URIs “portals” for connection failover. I don’t have a ton of time to dig through the Discourse codebase and see which client driver you are using.
Lastly, we use SSL (using valid LE certs) for both Redis and PostgreSQL. Is your app configured for SSL support?
Thanks!
P.S. I’m reaching out personally, not officially from IBM/Compose. I enjoy Discourse and have been considering writing an article on how to configure Discourse using our services:
sam
(Sam Saffron)
2018 年 6 月 28 日午前 1:45
2
You can see all of the possible global vars documented at:
#
# DO NOT EDIT THIS FILE
# If you need to make changes create a file called discourse.conf in this directory with your changes
# On import this file will be imported using ERB
#
# Discourse supports multiple mechanisms for production config.
#
# 1. You can do nothing and get these defaults (not recommended, you should at least set hostname)
# 2. You can copy this file to config/discourse.conf and amend with your settings
# 3. You can pass in config from your environment, all the settings below are available.
# Prepend DISCOURSE_ and upper case the setting in ENV. For example:
# to pass in db_pool of 200 you would use DISCOURSE_DB_POOL=200
# All settings apply to production only
# connection pool size, sidekiq is set to 5, allowing an extra 3 for bg threads
db_pool = 8
# Database connection timeout in seconds
This file has been truncated. show original
You can pass in config from your environment, all the settings below are available.
Append DISCOURSE_ and upper case the setting in ENV. For example:
to pass in db_timeout of 200 you would use DISCOURSE_DB_TIMEOUT=200
vsoch
(Vanessasaurus)
2019 年 7 月 7 日午後 9:32
3
docker-compose アプリケーションでこれを行っていますが、DISCOURSE_REDIS_HOST 環境変数(値は redis)をエクスポートしているにもかかわらず、この変数が反映されません:
name, 'name', name),\n updated_at,\n created_at,\n updated_at\nFROM facebook_user_infos\n")
discourse_1_9cc0cea436ca | rake aborted!
discourse_1_9cc0cea436ca | Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)
discourse_1_9cc0cea436ca | /usr/local/bundle/gems/redis-4.0.1/lib/redis/client.rb:344:in `rescue in establish_connection'
完全なコードはこちら です。ご確認いただければ幸いです。何らかの理由で、反映されるべき変数が機能していません。背景として、私は プラグイン の開発を手伝いたいと考えていますが、参入障壁(ホストにすべてをインストールせずに基本的な開発環境を構築すること)が非常に高いです。Discourse が正常に動作したのは、Bitnami イメージを使用した時だけでしたが、どこかで「それは正しい方法ではない」と言われました。お手伝いください。これはこんなに難しくなるべきではありません。特に、貢献のために自分の自由な時間を割いているのに、そう感じるのは悔しいです
pfaffman
(Jay Pfaffman)
2019 年 7 月 8 日午前 12:29
4
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 1:19
5
もしかしたらコードの読み方を間違えているのかもしれませんが、bin/docker/boot_dev の --init スクリプトは、まだホスト上のデータベースや依存関係とやり取りしています。
2 つ目のスレッドについては、特にどこを見てほしいとおっしゃっているのでしょうか?投稿数が151件もあります。ありがとうございます!
Falco
(Falco)
2019 年 7 月 8 日午後 3:39
6
その変数は本番環境では問題なく機能します。
開発環境では、デフォルトでローカルインスタンスを検索します。これは、サポートされている開発環境のいずれかに従っていれば問題なく動作します。
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 7:08
7
本番環境を環境変数として実行していましたが、それが反映されませんでした。回避策として、sed で設定を変更したところ、解決しました。他にも多数の課題があり、現在対応中です。
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 7:10
8
例えば、明示的にデーモン化しないように指定して(コンテナを稼働させたままにするため)、以下のように実行しています:
bundle exec rails s --port 3000 --no-daemon --environment=production --binding 0.0.0.0
しかし、なぜかそれでもデーモン化されてしまいます!その結果、論理的にコンテナが終了してしまいます。
discourse_1_f60e0e3f1186 | [358] Puma starting in cluster mode...
discourse_1_f60e0e3f1186 | [358] * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
discourse_1_f60e0e3f1186 | [358] * Min threads: 8, max threads: 32
discourse_1_f60e0e3f1186 | [358] * Environment: production
discourse_1_f60e0e3f1186 | [358] * Process workers: 4
discourse_1_f60e0e3f1186 | [358] * Preloading application
discourse_1_f60e0e3f1186 | [358] * Listening on tcp://0.0.0.0:3000
discourse_1_f60e0e3f1186 | [358] * Daemonizing...
docker-compose-discourse_discourse_1_f60e0e3f1186 exited with code 0
引数や指示、環境変数などが用意されているにもかかわらず、実際にそれらが反映されないのは奇妙です。何を信じてよいのかわかりにくいです。
Falco
(Falco)
2019 年 7 月 8 日午後 7:11
9
本番環境と開発環境、どちらをお使いになりたいですか?
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 7:21
10
なぜ本番環境を実行して開発に使用できないのでしょうか?Sidekiq は何をするものでしょうか?アプリケーションを起動するには Sidekiq を単独で実行すべきですか?例えば、同じベースイメージの別のコンテナに以下の起動コマンドがあります。
bundle exec sidekiq
これはメインの Discourse コンテナ(データベースのマイグレーション、静的ファイルのプリコンパイルなど)に依存しています。すべてが機能しているように見えますが、Web アプリケーションが表示されません。
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 7:25
11
まだ何も始めていないので、この件には(より)多くの時間を割くことに喜んで取り組めます。ただし、ホストにデータベースをインストールする必要がない解決策が必要です。コンテナを使えば、そんなことをする必要はないはずです。再度申し上げますが、こちらの compose アプリケーション GitHub - vsoch/discourse-compose: docker-compose with discourse · GitHub は動作しているようです(ログにエラーは一切ありません)が、アプリケーション自体が存在しません。
pfaffman
(Jay Pfaffman)
2019 年 7 月 8 日午後 7:59
12
本番環境は多くのものをキャッシュし、プリコンパイルするため、事実上開発を不可能にしてしまうからです。
上記でリンクした Install Discourse for development using Docker はまさにそれを実現しています。
Sidekiq はジョブをキューに追加し、後で処理するために処理を行います。
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 8:13
13
何が足りないのでしょうか?–init のコマンドはホストで実行されます:
shift
done
if [[ $(docker info -f "{{.Architecture}}") != *x86_64* ]]; then
echo "WARNING: Docker architecture is not x86_64."
echo "Discourse development is unlikely to work using Docker's architecture emulation."
echo "Please try a native development installation."
sleep 1
fi
echo "Using source in: ${SOURCE_DIR}"
echo "Using data in: ${DATA_DIR}"
mkdir -p "${DATA_DIR}"
mount_plugin_symlinks=""
for symlink in $(find $PLUGINS_DIR -maxdepth 1 -type l); do
# `readlink -f` doesn't work on macOS, to fix it you need to override the `readlink` with `greadlink`
# > brew install coreutils
# > ln -s "$(which greadlink)" "$(dirname "$(which greadlink)")/readlink"
# reference: https://meta.discourse.org/t/beginners-guide-to-install-discourse-for-development-using-docker/102009/124?u=aleber
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 8:17
14
なるほどですが、ともかく私がプリコンパイルを実行している場合(それには時間がかかります!)、サーバーを起動しようとしたとき、なぜ動作しないのでしょうか?
vsoch
(Vanessasaurus)
2019 年 7 月 8 日午後 9:47
15
はい、折れて --init コマンドを実行しました。コンテナが実行中であることを確認できます:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d2254e1374f5 discourse/discourse_dev:release "/sbin/boot" 24 minutes ago Up 24 minutes 0.0.0.0:1080->1080/tcp, 0.0.0.0:3000->3000/tcp, 0.0.0.0:9292->9292/tcp, 0.0.0.0:9405->9405/tcp discourse_dev
しかし、どのポートからも記録が表示されません。2 つのブラウザ、localhost、127.0.0.1、0.0.0.0 を試しましたが、Web アプリケーションは表示されません。エラーは ERR_CONNECTION_RESET です。これをブロックする iptables の設定は確認できません:
Chain DOCKER (3 references)
target prot opt source destination
ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:9405
ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:9292
ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:3000
ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:socks
2019 年 7 月 10 日更新
皆様のご協力に感謝します。問題は「unicorn」コマンドを実行する必要があったことで、現在はすべて正常に動作しています。また、スタートコマンドで rake admin:create を実行する必要もありました。これを行わないと、メールでの確認を求められます(完全なリポジトリはこちら )。discourse_dev も問題なく動作します。