Skip to content

Update Mastodon from v2.6.5 to v2.7.0

kedama edited this page Jan 27, 2019 · 4 revisions

goal

  • update mastodon v2.6.5 to v2.7.0

need

  • update ruby v2.5.3 to v2.6.0

update ruby

run as mastodon user.

check current ruby version

~$ cd live
~/live$ ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]

fetch ruby-install repository

~/live$ cd ~/.rbenv/plugins/ruby-build/
~/.rbenv/plugins/ruby-build$ git fetch
remote: Enumerating objects: 254, done.
remote: Counting objects: 100% (254/254), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 307 (delta 233), reused 253 (delta 233), pack-reused 53
Receiving objects: 100% (307/307), 67.20 KiB | 882.00 KiB/s, done.
Resolving deltas: 100% (253/253), completed with 48 local objects.
From https://github.com/rbenv/ruby-build
   648fc99..434bedd  master     -> origin/master
 * [new tag]         v20181207  -> v20181207
 * [new tag]         v20181225  -> v20181225

checkout newest release tag

~/.rbenv/plugins/ruby-build$ git checkout v20181225

install ruby v2.6.0

⚠️ set TMPDIR environment variable if needed, ex: got message disk-full.

~$ cd
~$ echo $RUBY_CONFIGURE_OPTS
--with-jemalloc
~$ rbenv install 2.6.0

check installed

~$ rbenv versions
  2.5.3
  2.6.0

backup database

run as root.

stop mastodon

# systemctl stop mastodon-web
# systemctl stop mastodon-streaming
# systemctl stop mastodon-sidekiq

backup database

# sudo -u postgres pg_dumpall > /var/tmp/foresdon.jp.190127.dump
# gzip /var/tmp/foresdon.jp.190127.dump

update Mastodon to v2.7.0

run as mastodon user.

checkout Mastodon v2.7.0

~$ cd live
~/live$ git fetch
~/live$ git checkout v2.7.0

check ruby version

~/live$ ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]

update gems

~/live$ gem update --system
Updating rubygems-update
Fetching rubygems-update-3.0.2.gem
Successfully installed rubygems-update-3.0.2
Parsing documentation for rubygems-update-3.0.2
Installing ri documentation for rubygems-update-3.0.2
Installing darkfish documentation for rubygems-update-3.0.2
Done installing documentation for rubygems-update after 45 seconds
Parsing documentation for rubygems-update-3.0.2
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.0.2
Bundler 1.17.3 installed
RubyGems 3.0.2 installed
Regenerating binstubs
Parsing documentation for rubygems-3.0.2
Installing ri documentation for rubygems-3.0.2
 :
 :

update yarn

~/live$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash

install packages which Mastodon depends on

~/live$ bundle install
~/live$ yarn install

precompile assets & migrate db with SKIP_POST_DEPLOYMENT_MIGRATIONS=true

~/live$ RAILS_ENV=production bundle exec rails assets:precompile
~/live$ SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate

start Mastodon

run as root.

# systemctl start mastodon-sidekiq
# systemctl start mastodon-streaming
# systemctl start mastodon-web

migrate db post deployment

run as mastodon user.

~/live$ RAILS_ENV=production bundle exec rails db:migrate

trouble shooting

restart mastodon if got a 500 error when click "reblogged_by", "favourited_by", etc.

in puma-stdout.log:

[f9bc0481-f4a8-43c8-8255-c4b07063f12c] method=GET path=/api/v1/statuses/101486718349584742/reblogged_by format=html controller=Api::V1::Statuses::RebloggedByAccountsController action=index status=500 error='ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column accounts.statuses_count does not exist
[f9bc0481-f4a8-43c8-8255-c4b07063f12c] app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb:20:in `load_accounts'
[f9bc0481-f4a8-43c8-8255-c4b07063f12c] app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb:13:in `index'