忘れたころに mastodon update 手順メモ

mastodon を立てたはいいけど全然アップデートしていなかったのでアップデートする。


[centos@don ~]$ last
centos   pts/0        122-222-23-10.sa Sun May  6 12:37   still logged in
centos   pts/0        kd036012082083.a Sun Mar 25 11:50 - 11:50  (00:00)
centos   pts/0        kd036012091072.a Tue Mar  6 21:47 - 21:47  (00:00)
centos   pts/0        kd036012077074.a Sat Feb 10 07:57 - 07:57  (00:00)
centos   pts/0        217.81.32.202.bf Sun Nov 26 06:24 - 09:05  (02:40)
centos   pts/1        sp49-98-150-176. Mon Oct 30 04:47 - 04:48  (00:01)
centos   pts/0        sp49-98-150-176. Mon Oct 30 04:38 - 04:48  (00:09)

こんな感じのダメ管理者が行った備忘録です。

TL;DR

所要時間
コーヒー3杯、タバコ5本
サービスダウン時間
停止、DBのマイグレーション、プリコンパイル、起動まで。うちの環境で50分くらい※
対象
docker版のmastodonである
参考にさせてもらいました
Docker を利用したマストドンのアップデートメモ

※プリコンパイルを起動後にやって再起動する手順にすればもっと短縮できる気がする。


$ cd path/to/mastodon
$ git fetch
$ git stash
$ git tag
$ git checkout [バージョン番号]
$ git stash pop
$ sudo docker-compose pull
$ sudo docker-compose build
$ sudo docker-compose down
$ sudo docker-compose run --rm web rails db:migrate
$ sudo docker-compose run --rm web rails assets:precompile
$ sudo docker-compose up -d

やること

現在、ver 1.6.1 でした。最新版の 2.3.2 に上げます。

壊す前のバックアップ

よく壊しちゃうので、最悪何とかなるようバックアップしておきます。といっても、外側からざっくりとるバックアップです。気休めかもしれません。

mastodon インスタンスを探す

うちの mastodon は EC2 上にいるはずなので、そいつを探します。いました。

ボリュームのスナップショットをとる

ふむ。1つしかボリュームないので、そいつをクリックしてボリューム管理画面からスナップショットを作成します。

名前つけとかは適当に。

スナップショット管理画面で進捗を確認します。うちのは最大30GBみたいなので、すぐ終わるでしょう。コーヒー淹れてきます。

ステータスが緑のcompletedになれば完了です。
ちなみに、この方法で取得したバックアップを実際に使ったことないのでどこまで使えるのかはわかりませんよ。

どういう構成だったのか調べる

普通の人は、こんなこと必要ないと思います。でも、私って現場合わせの仕事が多いんで、普段からそういうのできるようにしておこうっていう勉強がてらあ・え・て、メモとか書かないんです。書いても読まないんです。その辺の話は追々書きたいな。

何が動いているかチェック

私流でいくと、ディストリビューションが何であるかとか、バージョンいくつであるとか、そういうの後回しです。とにかく、「ps -ef」です。


[centos@don ~]$ ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0  2017 ?        00:01:29 /usr/lib/systemd/systemd --switc
root         2     0  0  2017 ?        00:00:01 [kthreadd]
root         3     2  0  2017 ?        00:01:12 [ksoftirqd/0]
root         5     2  0  2017 ?        00:00:00 [kworker/0:0H]
root         7     2  0  2017 ?        00:00:00 [migration/0]
root         8     2  0  2017 ?        00:00:00 [rcu_bh]
root         9     2  0  2017 ?        00:47:16 [rcu_sched]
root        10     2  0  2017 ?        00:01:30 [watchdog/0]
root        12     2  0  2017 ?        00:00:00 [kdevtmpfs]
root        13     2  0  2017 ?        00:00:00 [netns]
root        14     2  0  2017 ?        00:00:00 [xenwatch]
root        15     2  0  2017 ?        00:00:00 [xenbus]
root        17     2  0  2017 ?        00:00:07 [khungtaskd]
root        18     2  0  2017 ?        00:00:00 [writeback]
root        19     2  0  2017 ?        00:00:00 [kintegrityd]
root        20     2  0  2017 ?        00:00:00 [bioset]
root        21     2  0  2017 ?        00:00:00 [kblockd]
root        22     2  0  2017 ?        00:00:00 [md]
root        27     2  0  2017 ?        00:03:23 [kswapd0]
root        28     2  0  2017 ?        00:00:00 [ksmd]
root        29     2  0  2017 ?        00:00:42 [khugepaged]
root        30     2  0  2017 ?        00:00:00 [crypto]
root        38     2  0  2017 ?        00:00:00 [kthrotld]
root        40     2  0  2017 ?        00:00:00 [kmpath_rdacd]
root        41     2  0  2017 ?        00:00:00 [kpsmoused]
root        43     2  0  2017 ?        00:00:00 [ipv6_addrconf]
root        62     2  0  2017 ?        00:00:00 [deferwq]
root        99     2  0  2017 ?        00:00:07 [kauditd]
root       205     2  0  2017 ?        00:00:00 [rpciod]
root       206     2  0  2017 ?        00:00:00 [xprtiod]
root       281     2  0  2017 ?        00:00:00 [ata_sff]
root       284     2  0  2017 ?        00:00:00 [scsi_eh_0]
root       285     2  0  2017 ?        00:00:00 [scsi_tmf_0]
root       286     2  0  2017 ?        00:00:00 [scsi_eh_1]
root       287     2  0  2017 ?        00:00:00 [scsi_tmf_1]
root       300     2  0  2017 ?        00:00:00 [bioset]
root       301     2  0  2017 ?        00:00:00 [xfsalloc]
root       302     2  0  2017 ?        00:00:00 [xfs_mru_cache]
root       303     2  0  2017 ?        00:00:00 [xfs-buf/xvda1]
root       304     2  0  2017 ?        00:00:00 [xfs-data/xvda1]
root       305     2  0  2017 ?        00:00:00 [xfs-conv/xvda1]
root       306     2  0  2017 ?        00:00:00 [xfs-cil/xvda1]
root       307     2  0  2017 ?        00:00:00 [xfs-reclaim/xvd]
root       308     2  0  2017 ?        00:00:00 [xfs-log/xvda1]
root       309     2  0  2017 ?        00:00:00 [xfs-eofblocks/x]
root       310     2  0  2017 ?        01:06:33 [xfsaild/xvda1]
root       388     1  0  2017 ?        00:02:27 /usr/lib/systemd/systemd-journal
root       420     1  0  2017 ?        00:00:00 /usr/sbin/lvmetad -f
root       433     1  0  2017 ?        00:00:00 /usr/lib/systemd/systemd-udevd
root       477     2  0  2017 ?        00:00:00 [ttm_swap]
root       492     2  0  2017 ?        00:00:00 [edac-poller]
root       517     2  0  2017 ?        00:00:16 [kworker/0:1H]
root       543     1  0  2017 ?        00:00:46 /sbin/auditd
root       562     1  0  2017 ?        00:12:23 /usr/sbin/rsyslogd -n
dbus       563     1  0  2017 ?        00:00:20 /bin/dbus-daemon --system --addr
polkitd    572     1  0  2017 ?        00:00:08 /usr/lib/polkit-1/polkitd --no-d
root       578     1  0  2017 ?        00:00:20 /usr/lib/systemd/systemd-logind
chrony     590     1  0  2017 ?        00:00:13 /usr/sbin/chronyd
root       604     1  0  2017 ?        00:00:15 /usr/sbin/gssproxy -D
root       787     1  0  2017 ?        00:00:09 /sbin/dhclient -1 -q -lf /var/li
root       846     1  0  2017 ?        00:26:50 /usr/bin/python -Es /usr/sbin/tu
root       953     1  0  2017 ?        00:00:31 /usr/libexec/postfix/master -w
postfix    957   953  0  2017 ?        00:00:05 qmgr -l -t unix -u
root      1002     1  0  2017 ?        03:59:06 /usr/bin/dockerd
root      1003     1  0  2017 ?        00:01:24 /usr/sbin/sshd -D
root      1006     1  0  2017 tty1     00:00:00 /sbin/agetty --noclear tty1 linu
root      1008     1  0  2017 ?        00:00:19 /usr/sbin/crond -n
root      1009     1  0  2017 ttyS0    00:00:00 /sbin/agetty --keep-baud 115200
root      1025  1002  0  2017 ?        02:31:56 docker-containerd -l unix:///var
root      1047     2  0  2017 ?        00:00:11 [loop0]
root      1049     2  0  2017 ?        00:00:00 [loop1]
root      1051     2  0  2017 ?        00:00:00 [kdmflush]
root      1054     2  0  2017 ?        00:00:00 [dm_bufio_cache]
root      1055     2  0  2017 ?        00:00:00 [bioset]
root      1056     2  0  2017 ?        00:00:00 [kcopyd]
root      1057     2  0  2017 ?        00:00:00 [bioset]
root      1058     2  0  2017 ?        00:00:00 [dm-thin]
root      1059     2  0  2017 ?        00:00:00 [bioset]
root      4403     2  0  2017 ?        00:00:00 [kdmflush]
root      4404     2  0  2017 ?        00:00:00 [bioset]
root      4407     2  0  2017 ?        00:00:00 [xfs-buf/dm-2]
root      4408     2  0  2017 ?        00:00:00 [xfs-data/dm-2]
root      4409     2  0  2017 ?        00:00:00 [xfs-conv/dm-2]
root      4410     2  0  2017 ?        00:00:00 [xfs-cil/dm-2]
root      4411     2  0  2017 ?        00:00:00 [xfs-reclaim/dm-]
root      4412     2  0  2017 ?        00:00:00 [xfs-log/dm-2]
root      4413     2  0  2017 ?        00:00:00 [xfs-eofblocks/d]
root      4414     2  0  2017 ?        00:00:00 [xfsaild/dm-2]
root      4418  1025  0  2017 ?        00:00:14 docker-containerd-shim 3a46c317e
70        4430  4418  0  2017 ?        00:01:07 postgres
root      4439     2  0  2017 ?        00:00:00 [kdmflush]
root      4440     2  0  2017 ?        00:00:00 [bioset]
root      4446     2  0  2017 ?        00:00:00 [xfs-buf/dm-1]
root      4447     2  0  2017 ?        00:00:00 [xfs-data/dm-1]
root      4448     2  0  2017 ?        00:00:00 [xfs-conv/dm-1]
root      4449     2  0  2017 ?        00:00:00 [xfs-cil/dm-1]
root      4450     2  0  2017 ?        00:00:00 [xfs-reclaim/dm-]
root      4451     2  0  2017 ?        00:00:00 [xfs-log/dm-1]
root      4452     2  0  2017 ?        00:00:00 [xfs-eofblocks/d]
root      4453     2  0  2017 ?        00:00:00 [xfsaild/dm-1]
root      4458  1025  0  2017 ?        00:00:25 docker-containerd-shim f24c92fc1
root      4464  1003  0 12:37 ?        00:00:00 sshd: centos [priv]
centos    4466  4464  0 12:37 ?        00:00:00 sshd: centos@pts/0
centos    4468  4466  0 12:37 pts/0    00:00:00 -bash
100       4472  4458  0  2017 ?        07:08:13 redis-server
70        4575  4430  0  2017 ?        00:00:06 postgres: checkpointer process
70        4576  4430  0  2017 ?        00:03:17 postgres: writer process
70        4577  4430  0  2017 ?        00:03:16 postgres: wal writer process
70        4578  4430  0  2017 ?        00:01:29 postgres: autovacuum launcher pr
70        4579  4430  0  2017 ?        00:02:37 postgres: stats collector proces
root      6867     2  0 Apr24 ?        00:00:13 [kworker/u30:0]
postfix   8627   953  0 13:14 ?        00:00:00 pickup -l -t unix -u
70        8839  4430  0 Mar15 ?        00:00:10 postgres: postgres postgres 172.
root     10869     2  0 13:35 ?        00:00:00 [kworker/0:1]
70       11857  4430  0  2017 ?        00:00:07 postgres: postgres postgres 172.
70       11859  4430  0  2017 ?        00:00:10 postgres: postgres postgres 172.
70       11867  4430  0  2017 ?        00:00:00 postgres: postgres postgres 172.
70       11868  4430  0  2017 ?        00:00:00 postgres: postgres postgres 172.
root     12013     1  0  2017 ?        00:00:00 nginx: master process /usr/sbin/
nginx    12015 12013  0  2017 ?        00:00:54 nginx: worker process
root     12032     2  0 13:45 ?        00:00:00 [kworker/0:0]
root     12655     2  0 13:51 ?        00:00:00 [kworker/0:2]
70       13279  4430  0 Apr28 ?        00:00:00 postgres: postgres postgres 172.
root     13771  1008  0 14:01 ?        00:00:00 /usr/sbin/CROND -n
root     13772 13771  0 14:01 ?        00:00:00 /bin/bash /bin/run-parts /etc/cr
root     13784 13772  1 14:01 ?        00:00:00 /usr/bin/python -tt /usr/sbin/yu
root     13785 13772  0 14:01 ?        00:00:00 awk -v progname=/etc/cron.hourly
centos   13803  4468  0 14:01 pts/0    00:00:00 ps -ef
70       14467  4430  0  2017 ?        00:00:10 postgres: postgres postgres 172.
70       21385  4430  0  2017 ?        00:00:10 postgres: postgres postgres 172.
systemd+ 21985     1  0  2017 ?        00:02:56 /usr/lib/systemd/systemd-journal
70       22488  4430  0  2017 ?        00:00:06 postgres: postgres postgres 172.
root     23361     2  0 May05 ?        00:00:01 [kworker/u30:1]
root     23792     2  0  2017 ?        00:00:00 [kdmflush]
root     23793     2  0  2017 ?        00:00:00 [bioset]
root     23796     2  0  2017 ?        00:00:00 [xfs-buf/dm-3]
root     23797     2  0  2017 ?        00:00:00 [xfs-data/dm-3]
root     23798     2  0  2017 ?        00:00:00 [xfs-conv/dm-3]
root     23799     2  0  2017 ?        00:00:00 [xfs-cil/dm-3]
root     23800     2  0  2017 ?        00:00:00 [xfs-reclaim/dm-]
root     23801     2  0  2017 ?        00:00:00 [xfs-log/dm-3]
root     23802     2  0  2017 ?        00:00:00 [xfs-eofblocks/d]
root     23803     2  0  2017 ?        00:00:00 [xfsaild/dm-3]
root     23812  1002  0  2017 ?        00:00:42 /usr/bin/docker-proxy -proto tcp
root     23828  1025  0  2017 ?        00:00:10 docker-containerd-shim cb208deff
991      23843 23828  0  2017 ?        00:06:26 /sbin/tini -- npm run start
root     23890     2  0  2017 ?        00:00:00 [kdmflush]
root     23891     2  0  2017 ?        00:00:00 [bioset]
root     23898     2  0  2017 ?        00:00:00 [xfs-buf/dm-4]
root     23899     2  0  2017 ?        00:00:00 [xfs-data/dm-4]
root     23900     2  0  2017 ?        00:00:00 [xfs-conv/dm-4]
root     23901     2  0  2017 ?        00:00:00 [xfs-cil/dm-4]
root     23902     2  0  2017 ?        00:00:00 [xfs-reclaim/dm-]
root     23903     2  0  2017 ?        00:00:00 [xfs-log/dm-4]
root     23904     2  0  2017 ?        00:00:00 [xfs-eofblocks/d]
root     23905     2  0  2017 ?        00:00:00 [xfsaild/dm-4]
root     23922  1002  0  2017 ?        00:01:01 /usr/bin/docker-proxy -proto tcp
root     23926  1025  0  2017 ?        00:00:14 docker-containerd-shim ff0f3b20f
991      23938 23926  0  2017 ?        00:06:18 /sbin/tini -- bundle exec rails
root     24067     2  0  2017 ?        00:00:00 [kdmflush]
root     24069     2  0  2017 ?        00:00:00 [bioset]
root     24073     2  0  2017 ?        00:00:00 [xfs-buf/dm-5]
root     24075     2  0  2017 ?        00:00:00 [xfs-data/dm-5]
root     24076     2  0  2017 ?        00:00:00 [xfs-conv/dm-5]
root     24077     2  0  2017 ?        00:00:00 [xfs-cil/dm-5]
root     24078     2  0  2017 ?        00:00:00 [xfs-reclaim/dm-]
root     24079     2  0  2017 ?        00:00:00 [xfs-log/dm-5]
root     24080     2  0  2017 ?        00:00:00 [xfs-eofblocks/d]
root     24081     2  0  2017 ?        00:00:00 [xfsaild/dm-5]
root     24094  1025  0  2017 ?        00:00:14 docker-containerd-shim 474a61cb9
991      24107 24094  0  2017 ?        00:05:15 /sbin/tini -- bundle exec sideki
991      24434 23843  0  2017 ?        00:00:00 npm
991      24450 23938  0  2017 ?        00:27:19 puma 3.10.0 (tcp://0.0.0.0:3000)
991      24483 24107  0  2017 ?        07:33:39 sidekiq 5.0.4 mastodon [0 of 5 b
991      24485 24434  0  2017 ?        00:00:00 sh -c node ./streaming/index.js
991      24486 24485  0  2017 ?        00:00:00 node ./streaming/index.js
991      24493 24486  0  2017 ?        00:01:02 /usr/bin/node /mastodon/streamin
70       24516  4430  0  2017 ?        00:00:00 postgres: postgres postgres 172.
70       24517  4430  0  2017 ?        00:00:00 postgres: postgres postgres 172.
991      24519 24450  0  2017 ?        00:30:35 puma: cluster worker 0: 125 [mas
991      24521 24450  0  2017 ?        00:27:29 puma: cluster worker 1: 125 [mas
70       24556  4430  0  2017 ?        00:00:07 postgres: postgres postgres 172.
70       24568  4430  0  2017 ?        00:00:00 postgres: postgres postgres 172.
70       24570  4430  0  2017 ?        00:00:00 postgres: postgres postgres 172.
70       24605  4430  0  2017 ?        00:00:06 postgres: postgres postgres 172.
telegraf 24790     1  0  2017 ?        09:23:53 /usr/bin/telegraf -config /etc/t
70       26807  4430  0 Mar19 ?        00:00:10 postgres: postgres postgres 172.

確認ポイント

  • PID 1 一番上のプロセスが何か
  • []がついてるのはひとまず無視
  • TIMEが多めのやつ
  • 知らない名前のやつがいないか

PID 1 のやつを見るのは、数年前までは init しかほぼなかったので気にする必要なかったんですけど、最近だと systemd が出てきたのでそれによって確認するポイントやコマンドが変わってくるので、その判断のためです。
TIMEが多めのやつってのは、要はたくさん動いてるやつなので何者かチェックしとく。
知らないやつは危険なのでちゃんとググる。

なるほど。と。ここまでで、dockerでmastodonが動いていて nginx, telegraf が個別に動いてるんやな。他はまぁいいか。ってことがわかりますね。

プロセスマネージャ?の情報見る

正式名称しらないけど、PID 1 のやつのことです。systemd なのでとりあえず、systemctl status とでも打っておきます。


[centos@don ~]$ systemctl status
● don.danmaid.com
    State: degraded
     Jobs: 0 queued
   Failed: 1 units
    Since: Sat 2017-09-30 18:21:39 UTC; 7 months 4 days ago
   CGroup: /
           ├─1 /usr/lib/systemd/systemd --switched-root --system --deserialize 2
           ├─docker
           │ ├─474a61cb99c3e3a444f93dddaaf3e7b3611c3cea9263c35df8594ae5d055a2dd
           │ │ ├─24107 /sbin/tini -- bundle exec sidekiq -q default -q mailers -
           │ │ └─24483 sidekiq 5.0.4 mastodon [0 of 5 busy]
           │ ├─ff0f3b20fd4728e9b402bde33055fd31d9b7147ea7adf7a0b64a00f5cdbd96b4
           │ │ ├─23938 /sbin/tini -- bundle exec rails s -p 3000 -b 0.0.0.0
           │ │ ├─24450 puma 3.10.0 (tcp://0.0.0.0:3000) [mastodon]
           │ │ ├─24519 puma: cluster worker 0: 125 [mastodon]
           │ │ └─24521 puma: cluster worker 1: 125 [mastodon]
           │ ├─cb208deff160e297186ec547af142a8e220b17489ec3834a4ec89bde2bdbc042
           │ │ ├─23843 /sbin/tini -- npm run start
           │ │ ├─24434 npm
           │ │ ├─24485 sh -c node ./streaming/index.js
           │ │ ├─24486 node ./streaming/index.js
           │ │ └─24493 /usr/bin/node /mastodon/streaming/index.js
           │ ├─f24c92fc1602ca13342f86a273ed91628c2cb685e9c8bbcb56998aaf63bc05c4
           │ │ └─4472 redis-server
           │ └─3a46c317e9f8424d5dc34662f910d8814478b6a6ff3c0965fead18962b966cc6
           │   ├─ 4430 postgres
           │   ├─ 4575 postgres: checkpointer process
           │   ├─ 4576 postgres: writer process
           │   ├─ 4577 postgres: wal writer process
           │   ├─ 4578 postgres: autovacuum launcher process
           │   ├─ 4579 postgres: stats collector process
           │   ├─ 8839 postgres: postgres postgres 172.18.0.5(51504) idl
           │   ├─11857 postgres: postgres postgres 172.18.0.5(35264) idl
           │   ├─11859 postgres: postgres postgres 172.18.0.5(35270) idl
           │   ├─11867 postgres: postgres postgres 172.18.0.6(45604) idl
           │   ├─11868 postgres: postgres postgres 172.18.0.6(45606) idl
           │   ├─13279 postgres: postgres postgres 172.18.0.5(58996) idl
           │   ├─14467 postgres: postgres postgres 172.18.0.5(36050) idl
           │   ├─21385 postgres: postgres postgres 172.18.0.5(54214) idl
           │   ├─22488 postgres: postgres postgres 172.18.0.5(54424) idl
           │   ├─24516 postgres: postgres postgres 172.18.0.5(58148) idl
           │   ├─24517 postgres: postgres postgres 172.18.0.6(40210) idl
           │   ├─24556 postgres: postgres postgres 172.18.0.5(58168) idl
           │   ├─24568 postgres: postgres postgres 172.18.0.6(40234) idl
           │   ├─24570 postgres: postgres postgres 172.18.0.6(40238) idl
           │   ├─24605 postgres: postgres postgres 172.18.0.5(58240) idl
           │   └─26807 postgres: postgres postgres 172.18.0.5(56516) idl
           ├─user.slice
           │ └─user-1000.slice
           │   └─session-5245.scope
           │     ├─ 4464 sshd: centos [priv]
           │     ├─ 4466 sshd: centos@pts/0
           │     ├─ 4468 -bash
           │     ├─15974 systemctl status
           │     └─15975 less
           └─system.slice
             ├─telegraf.service
             │ └─24790 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -co
             ├─nginx.service
             │ ├─12013 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx
             │ └─12015 nginx: worker process
             ├─systemd-journal-gatewayd.service
             │ └─21985 /usr/lib/systemd/systemd-journal-gatewayd
             ├─crond.service
             │ └─1008 /usr/sbin/crond -n
             ├─sshd.service
             │ └─1003 /usr/sbin/sshd -D
             ├─docker.service
             │ ├─ 1002 /usr/bin/dockerd
             │ ├─ 1025 docker-containerd -l unix:///var/run/docker/libcontainerd
             │ ├─ 4418 docker-containerd-shim 3a46c317e9f8424d5dc34662f910d88144
             │ ├─ 4458 docker-containerd-shim f24c92fc1602ca13342f86a273ed91628c
             │ ├─23812 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-p
             │ ├─23828 docker-containerd-shim cb208deff160e297186ec547af142a8e22
             │ ├─23922 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-p
             │ ├─23926 docker-containerd-shim ff0f3b20fd4728e9b402bde33055fd31d9
             │ └─24094 docker-containerd-shim 474a61cb99c3e3a444f93dddaaf3e7b361
             ├─tuned.service
             │ └─846 /usr/bin/python -Es /usr/sbin/tuned -l -P
             ├─postfix.service
             │ ├─ 953 /usr/libexec/postfix/master -w
             │ ├─ 957 qmgr -l -t unix -u
             │ └─8627 pickup -l -t unix -u
             ├─gssproxy.service
             │ └─604 /usr/sbin/gssproxy -D
             ├─systemd-logind.service
             │ └─578 /usr/lib/systemd/systemd-logind
             ├─polkit.service
             │ └─572 /usr/lib/polkit-1/polkitd --no-debug
             ├─network.service
             │ └─787 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth0.l
             ├─chronyd.service
             │ └─590 /usr/sbin/chronyd
             ├─dbus.service
             │ └─563 /bin/dbus-daemon --system --address=systemd: --nofork --nop
             ├─rsyslog.service
             │ └─562 /usr/sbin/rsyslogd -n
             ├─auditd.service
             │ └─543 /sbin/auditd
             ├─systemd-udevd.service
             │ └─433 /usr/lib/systemd/systemd-udevd
             ├─lvm2-lvmetad.service
             │ └─420 /usr/sbin/lvmetad -f
             ├─system-serial\x2dgetty.slice
             │ └─serial-getty@ttyS0.service
             │   └─1009 /sbin/agetty --keep-baud 115200 38400 9600 ttyS0 vt220
             ├─system-getty.slice
             │ └─getty@tty1.service
             │   └─1006 /sbin/agetty --noclear tty1 linux
             └─systemd-journald.service
               └─388 /usr/lib/systemd/systemd-journald

degradedですね。ぷ。。まぁ、予想通りの結果ですね。

dockerがどうなってるか確認

docker ps あたりで。あ、ちなみにわたし、dockerのこと詳しくないです。なので雰囲気でやってます。


[centos@don ~]$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
474a61cb99c3        gargron/mastodon    "/usr/local/bin/ru..."   7 months ago        Up 7 months         3000/tcp, 4000/tcp                 mastodon_sidekiq_1
ff0f3b20fd47        gargron/mastodon    "/usr/local/bin/ru..."   7 months ago        Up 7 months         0.0.0.0:3000->3000/tcp, 4000/tcp   mastodon_web_1
cb208deff160        gargron/mastodon    "/usr/local/bin/ru..."   7 months ago        Up 7 months         3000/tcp, 0.0.0.0:4000->4000/tcp   mastodon_streaming_1
f24c92fc1602        redis:alpine        "docker-entrypoint..."   7 months ago        Up 7 months         6379/tcp                           mastodon_redis_1
3a46c317e9f8        postgres:alpine     "docker-entrypoint..."   7 months ago        Up 7 months         5432/tcp                           mastodon_db_1

まぁ、mastodon関係のやつしかいないし、mastodon の docker-compose.yml を探して変更箇所確認しておけば平気かな。

docker-compose.yml を確認


[centos@don mastodon]$ cat docker-compose.yml
version: '3'
services:

  db:
    restart: always
    image: postgres:alpine
### Uncomment to enable DB persistance
    volumes:
      - ./postgres:/var/lib/postgresql/data

  redis:
    restart: always
    image: redis:alpine
### Uncomment to enable REDIS persistance
    volumes:
      - ./redis:/data

  web:
    build: .
    image: gargron/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    ports:
      - "3000:3000"
    depends_on:
      - db
      - redis
    volumes:
      - ./public/assets:/mastodon/public/assets
      - ./public/packs:/mastodon/public/packs
      - ./public/system:/mastodon/public/system

  streaming:
    build: .
    image: gargron/mastodon
    restart: always
    env_file: .env.production
    command: npm run start
    ports:
      - "4000:4000"
    depends_on:
      - db
      - redis

  sidekiq:
    build: .
    image: gargron/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec sidekiq -q default -q mailers -q pull -q push
    depends_on:
      - db
      - redis
    volumes:
      - ./public/system:/mastodon/public/system

postgresqlとredisをローカルにマップして永続化してるくらいしか変更点なさそうですね。

確認結果まとめ

  • docker版のmastodonである
  • nginxとtelegraf動いているけどそこは無視しよう

で、やりかたググります。
Docker を利用したマストドンのアップデートメモ

これで良さそうですね。いいねボタン押しておきます→Qiitaアカウント持ってなくて押せませんでしたゴメンなさい。

アップデート

手順通りに進めて行くだけですね。

ローカルリポジトリに反映


[centos@don mastodon]$ git fetch
error: cannot open .git/FETCH_HEAD: Permission denied

ぐはっ。慌てず確認。


[centos@don mastodon]$ ls -la
total 512
drwxr-xr-x. 17 root root   4096 Oct  2  2017 .
drwxr-xr-x.  4 root root     41 Oct 22  2017 ..
drwxr-xr-x. 15 root root    213 Sep 29  2017 app
-rw-r--r--.  1 root root   3370 Sep 29  2017 app.json
-rw-r--r--.  1 root root    124 Sep 29  2017 Aptfile
-rw-r--r--.  1 root root   1275 Sep 29  2017 .babelrc
drwxr-xr-x.  2 root root    126 Sep 29  2017 bin
-rw-r--r--.  1 root root   6059 Sep 29  2017 boxfile.yml
-rw-r--r--.  1 root root    135 Sep 29  2017 .buildpacks
-rw-r--r--.  1 root root    369 Sep 29  2017 Capfile
-rw-r--r--.  1 root root    290 Sep 29  2017 .codeclimate.yml
-rw-r--r--.  1 root root    665 Sep 29  2017 CODEOWNERS
drwxr-xr-x.  6 root root   4096 Sep 29  2017 config
-rw-r--r--.  1 root root    183 Sep 29  2017 config.ru
-rw-r--r--.  1 root root   2649 Sep 29  2017 CONTRIBUTING.md
drwxr-xr-x.  3 root root     54 Sep 29  2017 db
-rw-r--r--.  1 root root   1164 Sep 29  2017 docker-compose.yml
-rw-r--r--.  1 root root    647 Sep 29  2017 docker_entrypoint.sh
-rw-r--r--.  1 root root   1841 Sep 29  2017 Dockerfile
-rw-r--r--.  1 root root    120 Sep 29  2017 .dockerignore
drwxr-xr-x.  6 root root    173 Sep 29  2017 docs
-rw-r--r--.  1 root root    251 Sep 29  2017 .editorconfig
-rw-r--r--.  1 root root   3834 Sep 29  2017 .env.nanobox
-rw-r--r--   1 root root   5484 Oct  2  2017 .env.production
-rw-r--r--.  1 root root   4848 Sep 29  2017 .env.production.sample
-rw-r--r--.  1 root root    201 Sep 29  2017 .env.test
-rw-r--r--.  1 root root     38 Sep 29  2017 .env.vagrant
-rw-r--r--.  1 root root    639 Sep 29  2017 .eslintignore
-rw-r--r--.  1 root root   2634 Sep 29  2017 .eslintrc.yml
-rw-r--r--.  1 root root     23 Sep 29  2017 .foreman
-rw-r--r--.  1 root root   3131 Sep 29  2017 Gemfile
-rw-r--r--.  1 root root  15256 Sep 29  2017 Gemfile.lock
drwxr-xr-x.  8 root root    198 Oct  2  2017 .git
-rw-r--r--.  1 root root    520 Sep 29  2017 .gitattributes
-rw-r--r--.  1 root root   1045 Sep 29  2017 .gitignore
-rw-r--r--.  1 root root   1905 Sep 29  2017 .haml-lint.yml
-rw-r--r--.  1 root root    280 Sep 29  2017 ISSUE_TEMPLATE.md
drwxr-xr-x.  8 root root     98 Sep 29  2017 lib
-rw-r--r--.  1 root root  34520 Sep 29  2017 LICENSE
drwxr-xr-x.  2 root root     19 Sep 29  2017 log
drwxr-xr-x.  2 root root     85 Sep 29  2017 nanobox
-rw-r--r--.  1 root root    178 Sep 29  2017 .nanoignore
-rw-r--r--.  1 root root      2 Sep 29  2017 .nvmrc
-rw-r--r--.  1 root root   4792 Sep 29  2017 package.json
-rw-r--r--.  1 root root    169 Sep 29  2017 .postcssrc.yml
drwx------  19   70 root   4096 Sep 30  2017 postgres
-rw-r--r--.  1 root root     68 Sep 29  2017 Procfile
-rw-r--r--.  1 root root    171 Sep 29  2017 Procfile.dev
-rw-r--r--.  1 root root    150 Sep 29  2017 .profile
drwxr-xr-x.  9 root root   4096 Sep 30  2017 public
-rw-r--r--.  1 root root    249 Sep 29  2017 Rakefile
-rw-r--r--.  1 root root   4079 Sep 29  2017 README.md
drwxr-xr-x   2  100 root     22 May  6 14:48 redis
-rw-r--r--.  1 root root     46 Sep 29  2017 .rspec
-rw-r--r--.  1 root root   1643 Sep 29  2017 .rubocop.yml
-rw-r--r--.  1 root root      6 Sep 29  2017 .ruby-version
-rw-r--r--.  1 root root   3157 Sep 29  2017 scalingo.json
-rw-r--r--.  1 root root   7407 Sep 29  2017 .scss-lint.yml
-rw-r--r--.  1 root root     34 Sep 29  2017 .slugignore
drwxr-xr-x. 20 root root   4096 Sep 29  2017 spec
drwxr-xr-x.  2 root root     22 Sep 29  2017 streaming
-rw-r--r--.  1 root root   1140 Sep 29  2017 .travis.yml
-rw-r--r--.  1 root root   3943 Sep 29  2017 Vagrantfile
drwxr-xr-x.  3 root root     20 Sep 29  2017 vendor
-rw-r--r--.  1 root root 245589 Sep 29  2017 yarn.lock

まぁ、あるあるですけど、面倒だからって root で作業していたんでしょうねぇ。むろん、治すつもりもないので、 root で作業します。


[root@don mastodon]# git fetch
remote: Counting objects: 13313, done.
remote: Total 13313 (delta 6278), reused 6278 (delta 6278), pack-reused 7035
Receiving objects: 100% (13313/13313), 6.55 MiB | 0 bytes/s, done.
Resolving deltas: 100% (10351/10351), completed with 1186 local objects.
From https://github.com/tootsuite/mastodon
 * [new branch]      fix-account-statuses-counter-cache -> origin/fix-account-statuses-counter-cache
 * [new branch]      fix-reduce-collection-checks -> origin/fix-reduce-collection-checks
   b9c612b..e571de2  master     -> origin/master
From https://github.com/tootsuite/mastodon
 * [new tag]         v2.0.0     -> v2.0.0
 * [new tag]         v2.0.0rc1  -> v2.0.0rc1
 * [new tag]         v2.0.0rc2  -> v2.0.0rc2
 * [new tag]         v2.0.0rc3  -> v2.0.0rc3
 * [new tag]         v2.0.0rc4  -> v2.0.0rc4
 * [new tag]         v2.1.0     -> v2.1.0
 * [new tag]         v2.1.0rc1  -> v2.1.0rc1
 * [new tag]         v2.1.0rc2  -> v2.1.0rc2
 * [new tag]         v2.1.0rc3  -> v2.1.0rc3
 * [new tag]         v2.1.0rc4  -> v2.1.0rc4
 * [new tag]         v2.1.0rc5  -> v2.1.0rc5
 * [new tag]         v2.1.0rc6  -> v2.1.0rc6
 * [new tag]         v2.1.2     -> v2.1.2
 * [new tag]         v2.1.3     -> v2.1.3
 * [new tag]         v2.2.0     -> v2.2.0
 * [new tag]         v2.2.0rc1  -> v2.2.0rc1
 * [new tag]         v2.2.0rc2  -> v2.2.0rc2
 * [new tag]         v2.3.0     -> v2.3.0
 * [new tag]         v2.3.0rc1  -> v2.3.0rc1
 * [new tag]         v2.3.0rc2  -> v2.3.0rc2
 * [new tag]         v2.3.0rc3  -> v2.3.0rc3
 * [new tag]         v2.3.1     -> v2.3.1
 * [new tag]         v2.3.1rc1  -> v2.3.1rc1
 * [new tag]         v2.3.1rc2  -> v2.3.1rc2
 * [new tag]         v2.3.1rc3  -> v2.3.1rc3
 * [new tag]         v2.3.2     -> v2.3.2
 * [new tag]         v2.3.2rc1  -> v2.3.2rc1
 * [new tag]         v2.3.2rc2  -> v2.3.2rc2
 * [new tag]         v2.3.2rc3  -> v2.3.2rc3
 * [new tag]         v2.3.2rc4  -> v2.3.2rc4
 * [new tag]         v2.3.2rc5  -> v2.3.2rc5

変更点の退避


[root@don mastodon]# git stash
Saved working directory and index state WIP on v1.6.1: 4c14ff6 Oauth code in input form and add description message (#4986)
HEAD is now at 4c14ff6 Oauth code in input form and add description message (#4986)

タグ付き最新版へのアップデート


[root@don mastodon]# git tag
v0.1.0
v0.1.1
v0.1.2
v0.6
v0.7
v0.8
v0.9
v0.9.9
v1.0
v1.1
v1.1.1
v1.1.2
v1.2
v1.2.1
v1.2.2
v1.3
v1.3.1
v1.3.2
v1.3.3
v1.4.1
v1.4.2
v1.4.3
v1.4.4
v1.4.5
v1.4.6
v1.4.7
v1.4rc1
v1.4rc2
v1.4rc3
v1.4rc4
v1.4rc5
v1.4rc6
v1.5.0
v1.5.0rc1
v1.5.0rc2
v1.5.0rc3
v1.5.1
v1.6.0
v1.6.0rc1
v1.6.0rc2
v1.6.0rc3
v1.6.0rc4
v1.6.0rc5
v1.6.1
v2.0.0
v2.0.0rc1
v2.0.0rc2
v2.0.0rc3
v2.0.0rc4
v2.1.0
v2.1.0rc1
v2.1.0rc2
v2.1.0rc3
v2.1.0rc4
v2.1.0rc5
v2.1.0rc6
v2.1.2
v2.1.3
v2.2.0
v2.2.0rc1
v2.2.0rc2
v2.3.0
v2.3.0rc1
v2.3.0rc2
v2.3.0rc3
v2.3.1
v2.3.1rc1
v2.3.1rc2
v2.3.1rc3
v2.3.2
v2.3.2rc1
v2.3.2rc2
v2.3.2rc3
v2.3.2rc4
v2.3.2rc5
[root@don mastodon]# git checkout v2.3.2
Note: checking out 'v2.3.2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 6cc432b... Bump version to 2.3.2

なんか言ってますねぇ。英語?わかりませんよ。でも、雰囲気的にこれは問題ないヤツってことで無視しておきます。

ファイルの復帰


[root@don mastodon]# git stash pop
Auto-merging docker-compose.yml
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 2057 and retry the command.
# HEAD detached at v2.3.2
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#       modified:   docker-compose.yml
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (16c66f35e74a8a658637773ecb392d95e79d2f6f)

また何か言ってますねぇ。名前変更が多すぎるぜって言ってるようですね。でも、 modified: docker-compose.yml がいるのでOKってことにしましょう。中身を確認しておきます。


[root@don mastodon]# cat docker-compose.yml
version: '3'
services:

  db:
    restart: always
    image: postgres:9.6-alpine
    networks:
      - internal_network
### Uncomment to enable DB persistance
    volumes:
      - ./postgres:/var/lib/postgresql/data

  redis:
    restart: always
    image: redis:4.0-alpine
    networks:
      - internal_network
### Uncomment to enable REDIS persistance
    volumes:
      - ./redis:/data

#  es:
#    restart: always
#    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.3
#    environment:
#      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
#    networks:
#      - internal_network
#### Uncomment to enable ES persistance
##    volumes:
##      - ./elasticsearch:/usr/share/elasticsearch/data

  web:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    networks:
      - external_network
      - internal_network
    ports:
      - "3000:3000"
    depends_on:
      - db
      - redis
#      - es
    volumes:
      - ./public/assets:/mastodon/public/assets
      - ./public/packs:/mastodon/public/packs
      - ./public/system:/mastodon/public/system

  streaming:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: yarn start
    networks:
      - external_network
      - internal_network
    ports:
      - "4000:4000"
    depends_on:
      - db
      - redis

  sidekiq:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec sidekiq -q default -q mailers -q pull -q push
    depends_on:
      - db
      - redis
    networks:
      - external_network
      - internal_network
    volumes:
      - ./public/packs:/mastodon/public/packs
      - ./public/system:/mastodon/public/system

networks:
  external_network:
  internal_network:
    internal: true

なんか増えてるなぁ。でも、永続化のところはちゃんと反映されてるので問題ないでしょう。

Docker コンテナの更新


[root@don mastodon]# docker-compose pull
Pulling redis (redis:4.0-alpine)...
4.0-alpine: Pulling from library/redis
ff3a5c916c92: Pull complete
aae70a2e6027: Pull complete
87c655da471c: Pull complete
7f8fb829cc48: Pull complete
c72e0cff027d: Pull complete
276d6b52cd5b: Pull complete
Digest: sha256:8782054ba81c3b8b969dae4822263a97fc241a06f8f1fe1acacd7c077ec60831
Status: Downloaded newer image for redis:4.0-alpine
Pulling db (postgres:9.6-alpine)...
9.6-alpine: Pulling from library/postgres
ff3a5c916c92: Already exists
a503b44e1ce0: Pull complete
211706713093: Pull complete
222842002ceb: Pull complete
2300d8bd75d6: Pull complete
39a22e6e8a31: Pull complete
19df431193ff: Pull complete
2e91e6c28db4: Pull complete
6d438e926d3f: Pull complete
Digest: sha256:d1aebace5ef20d32cc7c96ba988766cdba7ce7fb462b463b03c020772f360765
Status: Downloaded newer image for postgres:9.6-alpine
Pulling streaming (tootsuite/mastodon:latest)...
latest: Pulling from tootsuite/mastodon
605ce1bd3f31: Pull complete
aa1516f902d4: Pull complete
454c63522b2c: Pull complete
ab02fb81eeac: Pull complete
b484d801baea: Pull complete
b83cd24fefb5: Pull complete
a62b9ad80b13: Pull complete
fe61c02d7607: Pull complete
8d27accee13a: Pull complete
082b9d506d39: Pull complete
dcc48bba52b6: Pull complete
Digest: sha256:d5af4a64db9ebabc2b2e86aa2b881454b5c0419f96bf5bc6e6fbb1a164c2a071
Status: Downloaded newer image for tootsuite/mastodon:latest
Pulling sidekiq (tootsuite/mastodon:latest)...
latest: Pulling from tootsuite/mastodon
Digest: sha256:d5af4a64db9ebabc2b2e86aa2b881454b5c0419f96bf5bc6e6fbb1a164c2a071
Status: Image is up to date for tootsuite/mastodon:latest
Pulling web (tootsuite/mastodon:latest)...
latest: Pulling from tootsuite/mastodon
Digest: sha256:d5af4a64db9ebabc2b2e86aa2b881454b5c0419f96bf5bc6e6fbb1a164c2a071
Status: Image is up to date for tootsuite/mastodon:latest

Docker のビルドと再起動

長いですね。コーヒー淹れてきましょう。


[root@don mastodon]# docker-compose build
redis uses an image, skipping
db uses an image, skipping
Building streaming
Step 1/20 : FROM ruby:2.4.3-alpine3.6

... 省略 ...

Step 20/20 : ENTRYPOINT /sbin/tini --
 ---> Using cache
 ---> ab43e481771e
Successfully built ab43e481771e
Successfully tagged tootsuite/mastodon:latest

問題なさそうですね。

マイグレーション


[root@don mastodon]# docker-compose run --rm web rails db:migrate
Creating network "mastodon_internal_network" with the default driver
Creating network "mastodon_external_network" with the default driver
Starting mastodon_redis_1 ...
Starting mastodon_db_1 ... done
rails aborted!
PG::ConnectionBad: could not translate host name "db" to address: Name does not resolve
/mastodon/vendor/bundle/ruby/2.4.0/gems/pg-0.21.0/lib/pg.rb:56:in `initialize'
/mastodon/vendor/bundle/ruby/2.4.0/gems/pg-0.21.0/lib/pg.rb:56:in `new'
/mastodon/vendor/bundle/ruby/2.4.0/gems/pg-0.21.0/lib/pg.rb:56:in `connect'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:695:in `connect'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:88:in `connection'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/schema_migration.rb:20:in `table_exists?'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/schema_migration.rb:24:in `create_table'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1125:in `initialize'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `new'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `up'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:985:in `migrate'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:58:in `block (2 levels) in '
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:46:in `invoke'
/mastodon/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/mastodon/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
bin/rails:4:in `
' Tasks: TOP => db:migrate (See full trace by running task with --trace)

ぐはっ。これはいかんですね。dbに接続できないみたい。
could not translate host name “db” to address: Name does not resolve
ですか。ん~、すでに起動してるからかなぁ。とりあえずググりますか。

お。
Mastodon v2.3.0の翻訳

トラブルシューティング
・Dockerでdocker-composerを使用し、PG::ConnectionBad: could not translate host name “db” to address: Name does not resolveが出る場合、docker-composeコマンドを走らせる前に、docker-compose down(Volumesを使用し、データを失わないようにしてください!)を実行する必要があるかもしれません。

ですよね!


[root@don mastodon]# docker-compose down
Stopping mastodon_sidekiq_1   ... done
Stopping mastodon_web_1       ... done
Stopping mastodon_streaming_1 ... done
Stopping mastodon_redis_1     ... done
Stopping mastodon_db_1        ... done
Removing mastodon_sidekiq_1   ... done
Removing mastodon_web_1       ... done
Removing mastodon_streaming_1 ... done
Removing mastodon_redis_1     ... done
Removing mastodon_db_1        ... done
Removing network mastodon_internal_network
Removing network mastodon_external_network
[root@don mastodon]# docker-compose run --rm web rails db:migrate
Creating network "mastodon_internal_network" with the default driver
Creating network "mastodon_external_network" with the default driver
Creating mastodon_redis_1 ...
Creating mastodon_db_1 ...
Creating mastodon_redis_1
Creating mastodon_redis_1 ... done
Migrating to AddHideNotificationsToMute (20170716191202)
== 20170716191202 AddHideNotificationsToMute: migrating =======================
-- transaction_open?()
   -> 0.0000s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- transaction()

... 省略 ...

Migrating to AddFeaturedCollectionUrlToAccounts (20180304013859)
== 20180304013859 AddFeaturedCollectionUrlToAccounts: migrating ===============
-- add_column(:accounts, :featured_collection_url, :string)
   -> 0.0006s
== 20180304013859 AddFeaturedCollectionUrlToAccounts: migrated (0.0006s) ======

おけ。問題なさそうです。

プリコンパイル

ここも、まずまず時間かかりますねぇ。タバコです。


[root@don mastodon]# docker-compose run --rm web rails assets:precompile
Starting mastodon_redis_1 ...
Starting mastodon_db_1 ... done
I, [2018-05-06T15:48:08.307861 #5]  INFO -- : Writing /mastodon/public/assets/pghero/application-3807e140de3bf52364d575c9c1cba1ed730999b53e2781da4bf8bb15b01791bf.js
I, [2018-05-06T15:48:08.308278 #5]  INFO -- : Writing /mastodon/public/assets/pghero/application-3807e140de3bf52364d575c9c1cba1ed730999b53e2781da4bf8bb15b01791bf.js.gz
Webpacker is installed 🎉 🍰
Using /mastodon/config/webpacker.yml file for setting up webpack paths
Compiling…

本当に動いているのか心配になりますねぇ。Duplicate Session しても反応返ってこないですねぇ。頑張っているんでしょう。
嫌だけど気になるので Enter 押してみました。30秒くらいしてから改行されましたね。大丈夫、動いてます。コーヒー淹れましょう。

やっと終わった。45分くらいかかりましたねぇ。


Compiled all packs in /mastodon/public/packs

起動です


[root@don mastodon]# docker-compose up -d
mastodon_redis_1 is up-to-date
mastodon_db_1 is up-to-date
Creating mastodon_sidekiq_1 ...
Creating mastodon_web_1 ...
Creating mastodon_streaming_1 ...
Creating mastodon_streaming_1
Creating mastodon_web_1
Creating mastodon_web_1 ... done

確認です

お疲れさまでした。