Mastodon customisations for queer.party
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

173 lines
3.1 KiB

#!/bin/sh
#Tunables
TUN_SDK_DF_COUNT=70
TUN_SDK_DF_DBCNT=80
TUN_SDK_PP_COUNT=35
TUN_SDK_PP_DBCNT=45
TUN_SDK_ML_COUNT=8
TUN_SDK_ML_DBCNT=10
TUN_WEB_CNC=2
TUN_WEB_THD=4
TUN_STR_NUM=4
TUN_MAINT_CARDS_LIFETIME=60
TUN_MAINT_MEDIA_LIFETIME=7
#Commands
CMD_WEB="bundle exec rails s -p 3000 -b 0.0.0.0"
CMD_STR="yarn start"
CMD_SDK="bundle exec sidekiq"
#Commands - Upgrades and Maintenance
CMD_MAINT_CARDS="bin/tootctl preview_cards remove"
CMD_MAINT_MEDIA="bin/tootctl media remove"
CMD_UPG_DB_PRE="SKIP_POST_DEPLOYMENT_MIGRATIONS=true rails db:migrate"
CMD_UPG_DB_ALL="rails db:migrate"
CMD_UPG_SG_SCH="bin/tootctl upgrade storage-schema"
#Paths
CFG_MASTODON="/configs/mastodon"
CFG_MAIL="/configs/mail"
CFG_DB="/configs/db"
CFG_ES="/configs/es"
CFG_SG="/configs/sg"
SCR_MASTODON="/secrets/mastodon"
SCR_MAIL="/secrets/mail"
SCR_DB="/secrets/db"
SCR_ES="/secrets/es"
SCR_SG="/secrets/sg"
SCR_PAPER="/secrets/paperclip"
SCR_VAPID="/secrets/vapid"
_log() {
echo "LOG : $*"
}
_warn() {
echo "WARN: $*"
}
_err() {
echo "ERR : $*" >/dev/stderr
}
load_to_env() {
echo "# included from $1" >> .env.production
cat $1 >> .env.production
echo >> .env.production
}
enrich() {
case "$1" in
mastodon)
load_to_env $CFG_MASTODON
load_to_env $SCR_MASTODON
;;
mail)
load_to_env $CFG_MAIL
load_to_env $SCR_MAIL
;;
db)
load_to_env $CFG_DB
load_to_env $SCR_DB
;;
es)
load_to_env $CFG_ES
#load_to_env $SCR_ES
;;
sg)
load_to_env $SCR_PAPER
load_to_env $CFG_SG
load_to_env $SCR_SG
;;
vapid)
load_to_env $SCR_VAPID
;;
*)
_err Configuration or secret not known.
exit 1
;;
esac
}
role_web() {
enrich mastodon
enrich db
enrich es
enrich sg
enrich vapid
enrich mail
rm -f /mastodon/tmp/pids/server.pid
export WEB_CONCURRENCY=$TUN_WEB_CNC
export MAX_THREADS=$TUN_WEB_THD
CMD_RUN="$CMD_WEB"
}
role_stream() {
enrich mastodon
enrich db
enrich sg
export STREAMING_CLUSTER_NUM=$TUN_STR_NUM
CMD_RUN="$CMD_STR"
}
role_sk_main() {
enrich mastodon
enrich db
enrich es
enrich sg
enrich vapid
export DB_POOL=$TUN_SDK_DF_DBCNT
CMD_RUN="$CMD_SDK -c $TUN_SDK_DF_COUNT -q default"
}
role_sk_pushpull() {
enrich mastodon
enrich db
enrich es
enrich vapid
enrich sg
export DB_POOL=$TUN_SDK_PP_DBCNT
CMD_RUN="$CMD_SDK -c $TUN_SDK_PP_COUNT -q push -q pull"
}
role_sk_mail() {
enrich mastodon
enrich db
enrich mail
export DB_POOL=$TUN_SDK_ML_DBCNT
CMD_RUN="$CMD_SDK -c $TUN_SDK_ML_COUNT -q mailers"
}
role_sk() {
if [ "x$QUEUE" = "x" ]; then
_err Sidekiq queue not configured.
exit 1
fi
case "$QUEUE" in
main) role_sk_main;;
pushpull) role_sk_pushpull;;
mail) role_sk_mail;;
*)
_err Sidekiq queue not recognised.
exit 1
;;
esac
}
role_maint_cards() {
enrich mastodon
enrich db
enrich sg
CMD_RUN="$CMD_MAINT_CARDS --days=$TUN_MAINT_CARDS_LIFETIME"
}
role_maint_media() {
enrich mastodon
enrich db
enrich sg
CMD_RUN="$CMD_MAINT_MEDIA --days=$TUN_MAINT_MEDIA_LIFETIME"
}
role_maint() {
if [ "x$MTASK" = "x" ]; then
_err Maintenance task not defined.
exit 1
fi
case "$MTASK" in
cards) role_maint_cards;;
media) role_maint_media;;
*)
_err Maintenance task not recognised.
exit 1
;;
esac
}