# HG changeset patch # User Peter Gervai # Date 1616577488 -3600 # Node ID ba8922061637bc4d8f8aecf700df4d74e14cef04 # Parent 4216bf35912ecf0a827997cececad95079a10e20 Move synapse stuff into synapse/ dir diff -r 4216bf35912e -r ba8922061637 _config.sh --- a/_config.sh Wed Mar 24 10:16:42 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -#!/bin/sh -# (cc) Peter 'grin' Gervai, 2020 - -#export DB="postgresql://matrixro:password@localhost:5432/synapse" -#export DBRW="postgresql://synapse:passwordd@localhost:5432/synapse" -#export T="MDAxNabCadacada111................" diff -r 4216bf35912e -r ba8922061637 media_purge.sh --- a/media_purge.sh Wed Mar 24 10:16:42 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#!/bin/sh -# purge (foreign) media cache -# (cc) Peter 'grin' Gervai, 2020 - -# import $T access token (macaroon) -. /root/matrix-synapse/clean_auto/_config.sh - -U="https://matrix.grin.hu:8448/" -TM=`date +%s` - -# T - 1week -###TM=$(( TM - 60*60*24*7 )) - -# T - 1 hour -TM=$(( TM - 60*60 )) - -printf "Purging up to %s\n", "`date --date="@${TM}"`" -TM="${TM}000" -STAMP=$TM - -MODE="POST" -#CMD="_matrix/client/r0/admin/purge_media_cache?before_ts=$STAMP" -CMD="_synapse/admin/v1/purge_media_cache?before_ts=$STAMP" - -time curl -s -d '{}' -X${MODE} "${U}${CMD}&access_token=$T" | jq diff -r 4216bf35912e -r ba8922061637 run_compress.sh --- a/run_compress.sh Wed Mar 24 10:16:42 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -#!/bin/sh -# compress synapse database room graphs -# (cc) Peter 'grin' Gervai, 2020 - -ARG="$1" - -source _config.sh - -set -x -CMD="SELECT room_id, COUNT(*), type FROM state_groups_state GROUP BY 1,3 HAVING COUNT(*)>999999 ORDER BY 2 DESC;" - -BASE="/root/matrix-synapse/clean_auto" -LOG="${BASE}/process.log" - -savelog -c 4 $LOG - -TMP=`mktemp /tmp/synapse_compress.XXXXXXXX` - -echo "==== `date +%F_%T` now." >> ${LOG} - -if [ "x$ARG" = "x" ]; then - echo "Collecting room/state groups data..." | tee -a ${LOG} - if ! psql "${DB}" synapse -tAc "${CMD}" > $TMP; then - echo "Error getting room stats. Exit." - exit 1 - fi -else - echo "Processing already collected data ${ARG}." - rm "${TMP}" - TMP="$ARG" -fi - - -awk -F'|' '{print $1}' < $TMP | while read room; do - NOW=`date +%F_%T` - echo "Processing room ${room}... into c${NOW}_compress.sql" | tee -a ${LOG} - /usr/bin/time ../synapse-compress-state -o "c${NOW}_compress.sql" -p "${DB}" -t -r "${room}" | tee -a ${LOG} - echo "Actually compressing (c${NOW}_compress.sql)..." | tee -a ${LOG} - /usr/bin/time psql "${DBRW}" synapse -f "c${NOW}_compress.sql" | tee -a ${LOG} -done -echo "We shall delete ${TMP} file." | tee -a ${LOG} -set +x - \ No newline at end of file diff -r 4216bf35912e -r ba8922061637 synapse/_config.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/synapse/_config.sh Wed Mar 24 10:18:08 2021 +0100 @@ -0,0 +1,6 @@ +#!/bin/sh +# (cc) Peter 'grin' Gervai, 2020 + +#export DB="postgresql://matrixro:password@localhost:5432/synapse" +#export DBRW="postgresql://synapse:passwordd@localhost:5432/synapse" +#export T="MDAxNabCadacada111................" diff -r 4216bf35912e -r ba8922061637 synapse/media_purge.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/synapse/media_purge.sh Wed Mar 24 10:18:08 2021 +0100 @@ -0,0 +1,25 @@ +#!/bin/sh +# purge (foreign) media cache +# (cc) Peter 'grin' Gervai, 2020 + +# import $T access token (macaroon) +. /root/matrix-synapse/clean_auto/_config.sh + +U="https://matrix.grin.hu:8448/" +TM=`date +%s` + +# T - 1week +###TM=$(( TM - 60*60*24*7 )) + +# T - 1 hour +TM=$(( TM - 60*60 )) + +printf "Purging up to %s\n", "`date --date="@${TM}"`" +TM="${TM}000" +STAMP=$TM + +MODE="POST" +#CMD="_matrix/client/r0/admin/purge_media_cache?before_ts=$STAMP" +CMD="_synapse/admin/v1/purge_media_cache?before_ts=$STAMP" + +time curl -s -d '{}' -X${MODE} "${U}${CMD}&access_token=$T" | jq diff -r 4216bf35912e -r ba8922061637 synapse/run_compress.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/synapse/run_compress.sh Wed Mar 24 10:18:08 2021 +0100 @@ -0,0 +1,43 @@ +#!/bin/sh +# compress synapse database room graphs +# (cc) Peter 'grin' Gervai, 2020 + +ARG="$1" + +source _config.sh + +set -x +CMD="SELECT room_id, COUNT(*), type FROM state_groups_state GROUP BY 1,3 HAVING COUNT(*)>999999 ORDER BY 2 DESC;" + +BASE="/root/matrix-synapse/clean_auto" +LOG="${BASE}/process.log" + +savelog -c 4 $LOG + +TMP=`mktemp /tmp/synapse_compress.XXXXXXXX` + +echo "==== `date +%F_%T` now." >> ${LOG} + +if [ "x$ARG" = "x" ]; then + echo "Collecting room/state groups data..." | tee -a ${LOG} + if ! psql "${DB}" synapse -tAc "${CMD}" > $TMP; then + echo "Error getting room stats. Exit." + exit 1 + fi +else + echo "Processing already collected data ${ARG}." + rm "${TMP}" + TMP="$ARG" +fi + + +awk -F'|' '{print $1}' < $TMP | while read room; do + NOW=`date +%F_%T` + echo "Processing room ${room}... into c${NOW}_compress.sql" | tee -a ${LOG} + /usr/bin/time ../synapse-compress-state -o "c${NOW}_compress.sql" -p "${DB}" -t -r "${room}" | tee -a ${LOG} + echo "Actually compressing (c${NOW}_compress.sql)..." | tee -a ${LOG} + /usr/bin/time psql "${DBRW}" synapse -f "c${NOW}_compress.sql" | tee -a ${LOG} +done +echo "We shall delete ${TMP} file." | tee -a ${LOG} +set +x + \ No newline at end of file