Upgrading Mastodon on FreeBSD

Stop the three Mastodon servers.
# service mastodon_web stop
# service mastodon_workers stop
# service mastodon_stream stop
Upgrade the Mastodon package.
# pkg upgrade mastodon
Switch to the mastodon user.
# sudo su - mastodon
Remove the old Gemfile.lock.
% rm Gemfile.lock
Check the release notes to see if the javascript dependencies need to be updated. If they do, run this.
% yarn install
When upgrading to version 1.4.3, an extra step needs to be run before the database migration.
% RAILS_ENV=production rails mastodon:maintenance:prepare_for_foreign_keys
Check the release notes to see if the database migration script needs to be run. If it does, run this.
% RAILS_ENV=production rails db:migrate
Check the release notes to see if the new release includes changes to assets. If it does, run this.
% RAILS_ENV=production rails assets:precompile
Return to root privileges and restart the Mastodon daemons.
# service mastodon_web start
# service mastodon_workers start
# service mastodon_stream start

Posted 2017-04-27 12:55 | Comments

Running Mastodon on FreeBSD

Here is how to to get Mastodon running on FreeBSD using the FreeBSD port/package. What follows is based on the official Mastodon production Guide.

Install the packages

# pkg install nginx postgesql93-server postgesql93-contrib sudo mastodon

Enable and start required services

# sysrc redis_enable="YES"
# service redis start
# sysrc postgresql_enable="YES"
# service postgresql initdb
# service postgresql start
The Mastodon port ships with two sample nginx configuration files, a complete nginx.conf and nginx-include.conf, which mostly just includes the server block. If the web server is going to be dedicated to Mastodon, you can create a new nginx profile.
# sysrc nginx_profiles=mastodon
# sysrc nginx_mastodon_configfile="/usr/local/www/mastodon/nginx.conf"
If you prefer to continue using your current nginx.conf, you can add the line below to it. Make sure you put it inside the http block.
include /usr/local/www/mastodon/nginx-include.conf;
In either case, you need to customize nginx-include.conf. At minimum, you will have to change all instances of example.com. Once you are satisfied with its configuration, start nginx.
# sysrc nginx_enable="YES"
# service nginx start

Create mastodon database user

# psql -d template1 -U pgsql -c "CREATE USER mastodon CREATEDB;"

Switch to the mastodon user

# sudo su - mastodon

Customize .env.production

Customize .env.production to suit your needs, but you must at least set values for LOCAL_DOMAIN and SMTP_FROM_ADDRESS. You also have to generate secrets for PAPERCLIP_SECRET, SECRET_KEY_BASE, and OTP_SECRET. Generate a different secret for each of these fields by running the commands below.
% irb
>> require 'securerandom'
>> SecureRandom.hex(64)
>> SecureRandom.hex(64)
>> SecureRandom.hex(64)
>> exit  

Set up the database for the first time

% RAILS_ENV=production rails db:setup

Pre-compile all CSS and JavaScript files

% RAILS_ENV=production rails assets:precompile

Start the Mastodon daemons

Run the following commands with root privileges.
# sysrc mastodon_web_enable="YES"
# sysrc mastodon_workers_enable="YES"
# sysrc mastodon_stream_enable="YES"
# service mastodon_web start
# service mastodon_workers start
# service mastodon_stream start

Enable the daily periodic tasks

Add the line below to /etc/periodic.conf.

Posted 2017-04-23 21:18 | Comments

Recent posts

Monthly Archives

Yearly Archives