forked from silvio/docker-matrix
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update synapse, PostgreSQL migration
- opened up 8448 to matrix clients for probable resolution of hardcoded integrations server ports in Riot element-hq/element-web#3329 (comment) - migrated to PostgreSQL due to speed issues - learned opening twentythousand ports in Docker creates twentythousand docker-proxy processes for this, which makes the daemon run into cgroups memory issues
- Loading branch information
Showing
4 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
OPTION="${1}" | ||
|
||
if [ ! -z "${ROOTPATH}" ]; then | ||
echo ":: We have changed the semantic and doesn't need the ROOTPATH" | ||
echo ":: variable anymore" | ||
fi | ||
|
||
case $OPTION in | ||
"start") | ||
echo "-=> start matrix" | ||
python -m synapse.app.homeserver \ | ||
--config-path /data/homeserver.yaml \ | ||
;; | ||
"stop") | ||
echo "-=> stop matrix" | ||
echo "-=> via docker stop ..." | ||
;; | ||
"version") | ||
VERSION=$(tail -n 1 /synapse.version) | ||
echo "-=> Matrix Version: ${VERSION}" | ||
;; | ||
"migrate") | ||
synapse_port_db \ | ||
--sqlite-database /data/homeserver.db \ | ||
--postgres-config /data/homeserver.yaml \ | ||
--curses | ||
;; | ||
"generate") | ||
breakup="0" | ||
[[ -z "${SERVER_NAME}" ]] && echo "STOP! environment variable SERVER_NAME must be set" && breakup="1" | ||
[[ -z "${REPORT_STATS}" ]] && echo "STOP! environment variable REPORT_STATS must be set to 'no' or 'yes'" && breakup="1" | ||
[[ "${breakup}" == "1" ]] && exit 1 | ||
|
||
[[ "${REPORT_STATS}" != "yes" ]] && [[ "${REPORT_STATS}" != "no" ]] && \ | ||
echo "STOP! REPORT_STATS needs to be 'no' or 'yes'" && breakup="1" | ||
|
||
echo "-=> generate synapse config" | ||
python -m synapse.app.homeserver \ | ||
--config-path /data/homeserver.yaml \ | ||
--generate-config \ | ||
--report-stats ${REPORT_STATS} \ | ||
--server-name ${SERVER_NAME} | ||
|
||
export TURNKEY=$(</data/TURNKEY) | ||
echo "-=> configure some settings in homeserver.yaml" | ||
awk -v SERVER_NAME="${SERVERNAME}" \ | ||
-v TURNURIES="turn_uris: [\"turn:${SERVER_NAME}:3478?transport=udp\", \"turn:${SERVER_NAME}:3478?transport=tcp\"]" \ | ||
-v TURNSHAREDSECRET="turn_shared_secret: \"${TURNKEY}\"" \ | ||
-v PIDFILE="pid_file: /data/homeserver.pid" \ | ||
-v DATABASE="database: \"/data/homeserver.db\"" \ | ||
-v LOGFILE="log_file: \"/data/homeserver.log\"" \ | ||
-v MEDIASTORE="media_store_path: \"/data/media_store\"" \ | ||
'{ | ||
sub(/turn_shared_secret: "YOUR_SHARED_SECRET"/, TURNSHAREDSECRET); | ||
sub(/turn_uris: \[\]/, TURNURIES); | ||
sub(/pid_file: \/homeserver.pid/, PIDFILE); | ||
sub(/database: "\/homeserver.db"/, DATABASE); | ||
sub(/log_file: "\/homeserver.log"/, LOGFILE); | ||
sub(/media_store_path: "\/media_store"/, MEDIASTORE); | ||
print; | ||
}' /data/homeserver.yaml > /data/homeserver.tmp | ||
mv /data/homeserver.tmp /data/homeserver.yaml | ||
|
||
echo "-=> you can now review the generated configuration file homeserver.yaml" | ||
;; | ||
*) | ||
echo "-=> unknown \'$OPTION\'" | ||
;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
398d3ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is a mess, yet inspired by https://github.com/matrix-org/synapse/blob/master/docs/postgres.rst
398d3ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note how the generation is being run with the synapse image that also imposed its schema before 398d3ca#diff-2d86fed2d9f98642497ba4c54c2540caR14