Funkwhale

提供: ArchWiki
2024年1月17日 (水) 04:50時点におけるKgx (トーク | 投稿記録)による版 (→‎Initialization: 翻訳)
ナビゲーションに移動 検索に移動

関連記事

メインドキュメントページ: から引用

Funkwhale is a self-hosted, modern, free and open-source music server, heavily inspired by Grooveshark.

インスタンスは ActivityPub プロトコルで連携できます。

インストール

Funkwhale にはリバースプロキシ ([1]) が必要です。 したがって、nginx または Apache HTTP Server をインストールする必要があります。

また、設定された PostgreSQL データベースと Redis キャッシュサーバーも必要です。 詳細については、Funkwhale#設定 およびそれぞれのページを参照してください。

AUR からのインストール

funkwhaleAUR パッケージを インストール して下さい。

警告: このインストールでは Python virtualenv を使用しないため、すべての Python 依存関係は主に AUR からシステム全体にインストールされます。パッケージのバージョンが上流の要件と異なる場合があり、問題が発生する可能性があります。

手動インストール

[2] にある Arch のインストール手順に従ってください。 これにより、すべてのコンポーネントが /srv/funkwhale にインストールされます。

Docker のインストール

[3] にある Docker のインストール手順に従ってください。

設定

以下のセクションでは、Funkwhale が AUR からインストールされたことを前提としています。 手動インストールの場合は、フォルダーを適切に変更する必要があります。

また、ローカルネットワーク上で Funkwhale を使用していることも前提としています。 外部からアクセスできるようにする方法については、公式 ドキュメント を参照してください。 特に Certbot を使用する証明書の場合。

ホスト設定

/etc/hosts ファイルが正しく設定されていることを確認してください。 Funkwhale サーバーは、127.0.0.1 でエイリアス funkwhale.local で実行されていますが、これは変更できます。

/etc/hosts ファイルは次のようになります。

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1       localhost
::1             localhost
127.0.0.1       funkwhale.local

nginx の設定

Nginx 構成ファイルのアップストリーム テンプレートは、/etc/webapps/funkwhale/nginx.template で提供されます。 ただし、このファイルには、env ファイルの値で置き換える必要がある変数が含まれています (このファイルの作成方法についてはセクション 初期化 を参照してください):

$ set -a && source /srv/funkwhale/config/env && set +a
$ envsubst "`env | awk -F = '{printf \" $%s\", $$1}'`" \
   < /etc/webapps/funkwhale/nginx.conf \
   > /etc/nginx/sites-available/funkwhale.conf

証明書へのパスもそれに応じて変更する必要があります。

次に、サイトを有効にします:

$ ln -s /etc/nginx/sites-available/funkwhale.conf /etc/nginx/sites-enabled/

そして、nginx.service起動 します。

Apache の設定

ノート: RedisPostgreSQL、および Apache TLS サポートを使用して実行するように Apache HTTP Server を設定する必要があります。

テンプレートの Apache 設定ファイルは、/etc/webapps/funkwhale/apache-funkwhale.conf で提供されます。Funkwhale インスタンスが https://funkwhale.local でアクセスできるように設定されます。

フォルダー名は、インストールに合わせて変更する必要があります。どの行を変更する必要があるかについての詳細は、[4] で説明されています。

テンプレートを Apache 設定フォルダーにコピーし、

$ cp /etc/webapps/funkwhale/apache-funkwhale.conf /etc/httpd/conf/extra/funkwhale.conf

次に、Apache HTTP Server 設定ファイルを編集し、以下を追加します。

# /etc/httpd/conf/httpd.conf
Include conf/extra/funkwhale.conf

変更を適用するには、systemd を使用して httpd.service (Apache) を再起動する必要があります。

PostgreSQL の設定

ここでは、公式ドキュメントに従います: [5]

postgres ユーザーを使用して PostgreSQL コマンドラインに接続し、funkwhale ユーザーとデータベースを作成します。

$ sudo -u postgres psql
CREATE DATABASE "funkwhale"
 WITH ENCODING 'utf8';
CREATE USER funkwhale;
GRANT ALL PRIVILEGES ON DATABASE funkwhale TO funkwhale;
\c funkwhale;
CREATE EXTENSION "unaccent";
CREATE EXTENSION "citext";

最後の 3 行は、unaccent および citext 拡張機能をロードします。 これらは funkwhale が動作するために必要です (citext バージョン 0.20 以降)

初期化

Funkwhale ユーザー

Funkwhale は、funkwhale ユーザーとして実行する必要があります。これは、AUR パッケージによって自動的に作成されます。 手動インストールに従った場合は、次のように作成します。

# useradd -r -d /srv/funkwhale -m funkwhale -c "Funkwhale music server -s /sbin/nologin"

Funkwhale のデータフォルダーを /srv/funkwhale に作成します。 funkwhale ユーザーが所有:

# mkdir /srv/funkwhale
# chown funkwhale:funkwhale /srv/funkwhale

funkwhale ユーザーとして次のコマンドを実行します。

API ファイルとストレージ用のサブフォルダーを作成します:

[funkwhale]$ cd /srv/funkwhale
[funkwhale]$ mkdir -p api data/static data/media data/music config

Funkwhale が動作するには、いくつかの環境変数が必要です。これらは環境ファイル /srv/funkwhale/config/env で定義されている必要があります。 /etc/webapps/funkwhale/env.template にテンプレートがあります。これをコピーして、インストールに合わせて変更します。

[funkwhale]$ cp /etc/webapps/funkwhale/env.template /srv/funkwhale/config/env

FUNKWHALE_HOSTNAME 変数は、/etc/hosts のホスト名に対応する必要があります。 DJANGO_ALLOWED_HOSTS も、funkwhale インスタンスに到達するアドレスと一致する必要があります。 一意の DJANGO_SECRET_KEY を生成し、インストールに応じてパスを変更する必要があります。

ヒント: 環境変数がロードされた状態で funkwhale ユーザーとしていくつかのコマンドを実行する必要があるため、ログイン後に次のコマンドラインを使用できます:
[funkwhale]$ export $(grep -v ^#  /srv/funkwhale/config/env | xargs)

便宜上、この行を /srv/funkwhale/.bashrc (または使用しているシェル) にコピーすると、funkwhale ユーザーにログインするたびに自動的にロードされます。

データベースのセットアップ

AUR から funkwhale-venvAUR をインストールした場合は、/usr/bin/funkwhale_manage を使用して /usr/share/webapps/funkwhale/api/manage.py を実行しますfunkwhale ユーザーとしてコマンドを実行します。

アプリケーションを起動する前にデータベースを初期化します:

[funkwhale]$ funkwhale_manage migrate

Funkwhale インスタンスのスーパーユーザーを作成します:

[funkwhale]$ funkwhale_manage createsuperuser

Web アプリの静的ファイルを収集します:

[funkwhale]$ funkwhale_manage collectstatic
ノート: funkwhale_manage を使用しない場合は、まず Python virtualenv をアクティブにしてから、funkwhale ユーザーとしてコマンドを実行する必要があります。
[funkwhale]$ source /usr/share/webapps/funkwhale/virtualenv/bin/activate
[funkwhale]$ python /usr/share/webapps/funkwhale/api/manage.py migrate
[funkwhale]$ python /usr/share/webapps/funkwhale/api/manage.py createsuperuser
[funkwhale]$ python /usr/share/webapps/funkwhale/api/manage.py collectstatic
[funkwhale]$ deactivate

Version upgrade

ノート: Starting with version 0.21, an alias is provided for /usr/share/webapps/funkwhale/api/manage.py in /usr/bin/funkwhale_manage, so you can use:
[funkwhale]$ funkwhale_manage [commands...]

instead of

[funkwhale]$ python /usr/share/webapps/funkwhale/api/manage.py [commands...]

All commands should be entered as funkwhale user. Stop the funkwhale.service before upgrading.

The static files have to be collected again:

[funkwhale]$ funkwhale_manage collectstatic --no-input

Apply database migrations:

[funkwhale]$ funkwhale_manage migrate

To upgrade to version 1.0, the thumbnails quality has been increased from 70 to 95, so all the thumbnails should be regenerated (or set THUMBNAIL_JPEG_RESIZE_QUALITY=70 in the .env file so nothing changes). First delete the __sized__ directory in your MEDIA_ROOT directory, then regenerate the thumbnails,

[funkwhale]$ rm -rf /srv/funkwhale/data/media/__sized__
[funkwhale]$ funkwhale_manage fw media generate-thumbnails

Starting from version 0.20.1, there is a new MUSIC_USE_DENORMALIZATION parameter in the env file set to True (you can set it to False so nothing changes). It is a performance enhancement and to make it work you need to run the following command,

[funkwhale]$ python /usr/share/webapps/funkwhale/api/manage.py rebuild_music_permissions
警告: Check that the apache or nginx configuration file did not change before restarting the service. Consult the official documentation for incompatible changes.
警告: From version 0.20, python-daphneAUR was replaced by uvicorn/gunicorn. The service file was updated not to use python-daphneAUR anymore. This can be changed by editing the funkwhale-server.service file.

Also, the citext extension for postgresql is now needed. It can be loaded with issueing the following command before calling the migrate command:

$ sudo -u postgres psql funkwhale -c 'CREATE EXTENSION "citext";'

After completing all these steps, the funkwhale.service can be started again.

ノート: All the instructions for upgrading are given on the official documentation [6].

Usage

Upstream provides systemd services that are already installed with the AUR package.

To start the instance, just start funkwhale.service.

This starts three services, you can check their status with:

$ systemctl status funkwhale-\*

Troubleshooting

See https://docs.funkwhale.audio/admin/troubleshooting.html

Proxy logs

Apache logs for funkwhale:

$ tail -f /var/log/httpd/funkwhale/error.log