mastodon admin notes

this is the cron job that runs daily to do media and federation data cleanup:

#!/bin/sh

printf "%s: running cleanup tasks\n" "$(date)"
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove --days=7
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove --days=7 --remove-headers
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove --days=7 --prune-profiles
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove-orphans
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl preview_cards remove --days=30

printf "%s: dumping db\n" "$(date)"
pg_dump -Fc mastodon_production | ssh rsync "dd of=mastodon/db.dump"

date

this is the wrapper script i use to make sure i restart all necessary processes after updates.

root@mastodon:~# cat /usr/local/bin/masto
#!/bin/sh

case $1 in
        start|restart|stop|status)
                printf "%sing mastodon services\n" "$1"
                ;;

        logs)
                exec journalctl -fu mastodon-\*
                ;;
        *)
                printf "%s: invalid action. try logs, status, start, stop, restart.\n" "$1"
                exit 1
                ;;
esac

exec systemctl $1 mastodon-web \
        mastodon-streaming \
        mastodon-sidekiq@default \
        mastodon-sidekiq@pull \
        mastodon-sidekiq@push \
        mastodon-sidekiq@mailers \
        mastodon-sidekiq@scheduler \
        mastodon-sidekiq@ingress

the mastodon-sidekiq@.service units were added to address queues backing up and is essentially the same as the default unit file but with the -q queue name parameter added.


Comments

Leave a Reply