glitch-soc related

#建站合集SysAdmin Mostly the same as mainstream mastodon setting up as instructed here and here2.

Mostly except rbenv and git. And nginx, if you are as shit at it as I.

ruby

joinmastodon.org:

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.7.2
rbenv global 2.7.2

for glitch

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.7.3
rbenv global 2.7.3

git clone & git checkout

joinmastodon.org:

git clone https://github.com/tootsuite/mastodon.git live && cd live
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)

for glitch^3

git remote add glitch-soc https://github.com/glitch-soc/mastodon
git checkout glitch-soc/main

Updating the mastodon-glitch config

nano .env.production
systemctl daemon-reload
systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming

For taking changed configurations and regenerating dependency trees.

systemctl daemon-reload

Updating glitch from v3.3.0 to v3.4.0

Database backing up with postgresql in case something goes wrong (same as mastodon upstream)

sudo mkdir /opt/PGBACKUPS
sudo chown -R postgres:postgres /opt/PGBACKUPS
sudo su - postgres


pg_dump -U postgres -d mastodon_production > /opt/PGBACKUPS/mastodon_production$(date +%Y-%m-%d_%H_%M_%S).sql 

Upgrade

sudo su - mastodon  
cd /home/mastodon/live/
git stash 
git fetch glitch-soc
git checkout glitch-soc/main
git pull glitch-soc main

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.7.2
rbenv global 2.7.2
bundle install
yarn install
SKIP_POST_DEPLOYMENT_MIGRATIONS=true
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=production bundle exec rails assets:precompile
npx browserslist@latest --update-db 

systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
systemctl restart mastodon-streaming