lala.im:Mastodon实例升级方法

運維技術·lala.im · 2018-11-01 · 139 人浏览

原文地址:https://lala.im/4399.html,請支持原作者!該處僅作轉載。

有一台2.5.2版本的实例运行了一段时间了,昨天官方发布了最新版2.6.1,记录一下更新过程。。。
不过话说回来,真的不建议去经常升级这套程序,如果不是当前版本有严重漏洞的话,还是不要折腾的好,万一升炸了,就麻烦了。。
开始之前应该先停止运行Mastodon的所有服务:

systemctl stop mastodon-*

进入到项目目录:

cd live

如果是初次升级,首先应该配置git用户:

git config --global user.email "[email protected]"
git config --global user.name "imlala"

然后获取最新版本的代码:

git stash
git fetch --tags
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)

安装ruby依赖:

bundle install --deployment --without development test

安装node.js依赖:

yarn install --pure-lockfile

更新数据库:

RAILS_ENV=production bundle exec rails db:migrate

重新生成静态文件:

RAILS_ENV=production bundle exec rails assets:precompile

最后重新启动Mastodon的服务:

systemctl start mastodon-web.service
systemctl start mastodon-sidekiq.service
systemctl start mastodon-streaming.service

OK,现在应该成功升级到最新版本了:

範例
除这篇文章记录的步骤以外,在升级前你还应该仔细参考官方的releases页面:https://github.com/tootsuite/mastodon/releases
仔细看看新版本的发布记录,看有没有什么特别需要注意的地方,以防万一。。
还是要吐槽一下这个Mastodon,一定要在大于2GB内存的机器上面部署,1GB能跑但是跑的太吃力了,基本上几天就要用到800多MB内存,然后随便发点什么消息内存不够程序就卡死,因为跑在一台阿里云4.5刀的机器上,要升级到2G内存,价格直接翻了几倍,真是TM坑的一B,各位在部署之前一定要找好机器,因为这东西迁移非常麻烦。

運維技術 lala.im
Theme Jasmine by Kent Liao