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 - mastodoncd /opt/mastodonThis 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 --allCheckout 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.4bundle install && yarn install && RAILS_ENV=production bundle exec rails assets:precompilerestart-mastodonThis is an alias for:
sudo systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming && sleep 5 && sudo systemctl restart postgresqlCheck migrations:
RAILS_ENV=production bundle exec rails db:migrate:statusMigrate:
RAILS_ENV=production bundle exec rails db:migrateIf needs manual migrations, add:
RAILS_ENV=production bundle exec rails db:migrate:up VERSION=20230724160715After migrations you might need to clear cache before restart:
RAILS_ENV=production /opt/mastodon/bin/tootctl cache clearTest:
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-chewyRebuild 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-mastodonCreate new branch for new version based on fresh main/tag:
git branch mementomods-2024-07-11
git checkout mementomods-2024-07-11Attempt to merge previous branch:
git merge mementomods-2024-07-04If 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.productionRecompile:
bundle install && yarn install && RAILS_ENV=production bundle exec rails assets:precompilerestart-mastodonIt's good to clear cache sometimes:
RAILS_ENV=production /opt/mastodon/bin/tootctl cache clearStart Elasticsearch on dev:
sudo service elasticsearch startReset search index (on dev first: sudo service elasticsearch start):
RAILS_ENV=production bin/tootctl search deploy --reset-chewyIf 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-mastodonIt'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 pushSet 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.shFetch changes:
cd $HOME/live
git fetch --all
git checkout -b upstream/mementomods-2024-07-11
git pull upstream mementomods-2024-07-11Check that all changes are there:
git log --onelineUpdate version:
nano -w +62 .env.productionRebuild:
yarn cache clean# If needed, install whatever version is needed in this point
rbenv install 3.3.4bundle install && yarn install && RAILS_ENV=production bundle exec rails assets:precompileMigrate:
RAILS_ENV=production bundle exec rails db:migrate:statusRAILS_ENV=production bundle exec rails db:migrateClear cache:
RAILS_ENV=production /home/mastodon/live/bin/tootctl cache clearRun immediately:
sudo su -
/usr/local/bin/restart-mastodonOpen debug log:
sudo journalctl -u mastodon-web.service -fOr monitor fatals:
sudo journalctl -u mastodon-web.service -f |grep FATALDone!
Last updated