Mastodon upgrade workflow
This is the manual upgrade workflow for mementomori.social.
Test on the development environment
Start with logging in as the right user on your local Linux development environment.
sudo su - mastodon
cd /opt/mastodon
This branch is 45 commits behind mastodon/mastodon:main.
Steps
Go to GitHub
Take note: "This branch is X commits behind mastodon/mastodon:main", add note to part above.
Sync fork with main
Fetch all changes:
git fetch --all
Checkout main, build and test:
yarn cache clean && git checkout main && git pull
# If needed, install whatever version is needed in this point
rbenv install 3.3.4
bundle install && yarn install && RAILS_ENV=production bundle exec rails assets:precompile
restart-mastodon
This is an alias for:
sudo systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming && sleep 5 && sudo systemctl restart postgresql
Check migrations:
RAILS_ENV=production bundle exec rails db:migrate:status
Migrate:
RAILS_ENV=production bundle exec rails db:migrate
If needs manual migrations, add:
RAILS_ENV=production bundle exec rails db:migrate:up VERSION=20230724160715
After migrations you might need to clear cache before restart:
RAILS_ENV=production /opt/mastodon/bin/tootctl cache clear
Test:
Does the audio notification work
Does the emoji picker work
Does everything seem normal
Does the different feeds work (bookmarks, favs...)
Does the toot edits work from the arrow https://mementomori.test/@rolle/111668884903746596
Reset search index (on dev first: sudo service elasticsearch start):
RAILS_ENV=production bin/tootctl search deploy --reset-chewy
Rebuild search index:
RAILS_ENV=production bin/tootctl search deploy --only accounts --concurrency 16 --batch_size 4096;
RAILS_ENV=production bin/tootctl search deploy --only statuses --concurrency 16 --batch_size 4096;
Restart all services:
restart-mastodon
Create new branch for new version based on fresh main/tag:
git branch mementomods-2024-07-11
git checkout mementomods-2024-07-11
Attempt to merge previous branch:
git merge mementomods-2024-07-04
If it doesn't work with merge: Check the mods from last working branch, apply them on top of the branch and push the new working branch.
Update version:
nano +70 -w .env.production
Recompile:
bundle install && yarn install && RAILS_ENV=production bundle exec rails assets:precompile
restart-mastodon
It's good to clear cache sometimes:
RAILS_ENV=production /opt/mastodon/bin/tootctl cache clear
Start Elasticsearch on dev:
sudo service elasticsearch start
Reset search index (on dev first: sudo service elasticsearch start):
RAILS_ENV=production bin/tootctl search deploy --reset-chewy
If needed, build index for search:
RAILS_ENV=production bin/tootctl search deploy --only accounts --concurrency 16 --batch_size 4096;
RAILS_ENV=production bin/tootctl search deploy --only statuses --concurrency 16 --batch_size 4096;
Restart:
restart-mastodon
It's now time to test (If you see "Oops!An unexpected error occurred.", it is completely okay because we don't have access to the outside world.)
When everything works, push changes to git:
git push
Set upstream when asked.
Install on production
When everything works properly, login to mementomori.social on mastodon user.
Backup first:
sudo bash /usr/bin/backup-db.sh
Fetch changes:
cd $HOME/live
git fetch --all
git checkout -b upstream/mementomods-2024-07-11
git pull upstream mementomods-2024-07-11
Check that all changes are there:
git log --oneline
Update version:
nano -w +62 .env.production
Rebuild:
yarn cache clean
# If needed, install whatever version is needed in this point
rbenv install 3.3.4
bundle install && yarn install && RAILS_ENV=production bundle exec rails assets:precompile
Migrate:
RAILS_ENV=production bundle exec rails db:migrate:status
RAILS_ENV=production bundle exec rails db:migrate
Clear cache:
RAILS_ENV=production /home/mastodon/live/bin/tootctl cache clear
Run immediately:
sudo su -
/usr/local/bin/restart-mastodon
Open debug log:
sudo journalctl -u mastodon-web.service -f
Or monitor fatals:
sudo journalctl -u mastodon-web.service -f |grep FATAL
Done!
Last updated