diff --git a/changes/changelog.d/do-not-use-poetry-in-production-deployment.enhancement b/changes/changelog.d/do-not-use-poetry-in-production-deployment.enhancement new file mode 100644 index 000000000..9e87509db --- /dev/null +++ b/changes/changelog.d/do-not-use-poetry-in-production-deployment.enhancement @@ -0,0 +1 @@ +Don't use poetry in production deployments diff --git a/deploy/FreeBSD/funkwhale_beat b/deploy/FreeBSD/funkwhale_beat index cd5ca0c30..2c15ecfcf 100755 --- a/deploy/FreeBSD/funkwhale_beat +++ b/deploy/FreeBSD/funkwhale_beat @@ -26,9 +26,9 @@ funkwhale_beat_chdir="/usr/local/www/funkwhale/api" funkwhale_beat_user="funkwhale" funkwhale_beat_env="$(grep -v '^#' /usr/local/www/funkwhale/config/.env | xargs)" pidfile="/var/run/funkwhale/${name##funkwhale_}.pid" -command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3" +command_interpreter="/usr/local/www/funkwhale/venv/bin/python3" -command="/usr/local/www/funkwhale/virtualenv/bin/celery" +command="/usr/local/www/funkwhale/venv/bin/celery" command_args="\ --app funkwhale_api.taskapp \ beat \ diff --git a/deploy/FreeBSD/funkwhale_server b/deploy/FreeBSD/funkwhale_server index cc915422e..9878dcf85 100755 --- a/deploy/FreeBSD/funkwhale_server +++ b/deploy/FreeBSD/funkwhale_server @@ -25,9 +25,9 @@ load_rc_config "$name" funkwhale_server_chdir="/usr/local/www/funkwhale/api" funkwhale_server_user="funkwhale" funkwhale_server_env="$(grep -v '^#' /usr/local/www/funkwhale/config/.env | xargs)" -command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3" +command_interpreter="/usr/local/www/funkwhale/venv/bin/python3" -command="/usr/local/www/funkwhale/virtualenv/bin/gunicorn" +command="/usr/local/www/funkwhale/venv/bin/gunicorn" command_args="\ config.asgi:application \ --workers 4 \ diff --git a/deploy/FreeBSD/funkwhale_worker b/deploy/FreeBSD/funkwhale_worker index 4fa6adbea..a88c881e6 100755 --- a/deploy/FreeBSD/funkwhale_worker +++ b/deploy/FreeBSD/funkwhale_worker @@ -26,9 +26,9 @@ funkwhale_worker_chdir="/usr/local/www/funkwhale/api" funkwhale_worker_user="funkwhale" funkwhale_worker_env=$(grep -v '^#' /usr/local/www/funkwhale/config/.env | xargs) pidfile="/var/run/funkwhale/${name##funkwhale_}.pid" -command_interpreter="/usr/local/www/funkwhale/virtualenv/bin/python3" +command_interpreter="/usr/local/www/funkwhale/venv/bin/python3" -command="/usr/local/www/funkwhale/virtualenv/bin/celery" +command="/usr/local/www/funkwhale/venv/bin/celery" command_args="\ --app funkwhale_api.taskapp \ worker \ diff --git a/deploy/Gentoo/funkwhale_beat b/deploy/Gentoo/funkwhale_beat index 970b02908..71c64477e 100755 --- a/deploy/Gentoo/funkwhale_beat +++ b/deploy/Gentoo/funkwhale_beat @@ -5,7 +5,7 @@ NAME="funkwhalebeat" PIDFILE="/var/run/$NAME.pid" USER="funkwhale" WORKDIR="/srv/funkwhale/api" -Celery="/srv/funkwhale/virtualenv/bin/celery" +Celery="/srv/funkwhale/venv/bin/celery" BEAT_ARGS="--app funkwhale_api.taskapp beat --loglevel INFO" depend() { diff --git a/deploy/Gentoo/funkwhale_server b/deploy/Gentoo/funkwhale_server index e89167430..2f2d2702f 100755 --- a/deploy/Gentoo/funkwhale_server +++ b/deploy/Gentoo/funkwhale_server @@ -5,7 +5,7 @@ NAME="funkwhaleserver" PIDFILE="/var/run/$NAME.pid" USER="funkwhale" DAEMON_ARGS="config.asgi:application --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 127.0.0.1:5000" -Gunicorn="/srv/funkwhale/virtualenv/bin/gunicorn" +Gunicorn="/srv/funkwhale/venv/bin/gunicorn" WORKDIR="/srv/funkwhale/api" depend() { diff --git a/deploy/Gentoo/funkwhale_worker b/deploy/Gentoo/funkwhale_worker index 1df362b10..5a39514e1 100755 --- a/deploy/Gentoo/funkwhale_worker +++ b/deploy/Gentoo/funkwhale_worker @@ -5,7 +5,7 @@ NAME="funkwhaleworker" PIDFILE="/var/run/$NAME.pid" USER="funkwhale" WORKDIR="/srv/funkwhale/api" -Celery="/srv/funkwhale/virtualenv/bin/celery" +Celery="/srv/funkwhale/venv/bin/celery" WORKER_ARGS="--app funkwhale_api.taskapp worker --loglevel INFO" depend() { diff --git a/deploy/funkwhale-beat.service b/deploy/funkwhale-beat.service index 3fd851c9f..8ceb2dd06 100644 --- a/deploy/funkwhale-beat.service +++ b/deploy/funkwhale-beat.service @@ -8,7 +8,11 @@ User=funkwhale # adapt this depending on the path of your funkwhale installation WorkingDirectory=/srv/funkwhale/api EnvironmentFile=/srv/funkwhale/config/.env -ExecStart=/srv/funkwhale/.local/bin/poetry run celery -A funkwhale_api.taskapp beat -l INFO + +ExecStart=/srv/funkwhale/venv/bin/celery \ + --app funkwhale_api.taskapp \ + beat \ + --loglevel INFO [Install] WantedBy=multi-user.target diff --git a/deploy/funkwhale-server.service b/deploy/funkwhale-server.service index a996cf75c..688f9c2a8 100644 --- a/deploy/funkwhale-server.service +++ b/deploy/funkwhale-server.service @@ -8,6 +8,12 @@ User=funkwhale # adapt this depending on the path of your funkwhale installation WorkingDirectory=/srv/funkwhale/api EnvironmentFile=/srv/funkwhale/config/.env -ExecStart=/srv/funkwhale/.local/bin/poetry run gunicorn config.asgi:application -w ${FUNKWHALE_WEB_WORKERS} -k uvicorn.workers.UvicornWorker -b ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT} + +ExecStart=/srv/funkwhale/venv/bin/gunicorn \ + config.asgi:application \ + --workers ${FUNKWHALE_WEB_WORKERS} \ + --worker-class uvicorn.workers.UvicornWorker \ + --bind ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT} + [Install] WantedBy=multi-user.target diff --git a/deploy/funkwhale-worker.service b/deploy/funkwhale-worker.service index 2eff9b9d6..3386f7023 100644 --- a/deploy/funkwhale-worker.service +++ b/deploy/funkwhale-worker.service @@ -9,8 +9,12 @@ User=funkwhale WorkingDirectory=/srv/funkwhale/api Environment="CELERYD_CONCURRENCY=0" EnvironmentFile=/srv/funkwhale/config/.env -ExecStart=/srv/funkwhale/.local/bin/poetry run celery -A funkwhale_api.taskapp worker -l INFO --concurrency=${CELERYD_CONCURRENCY} +ExecStart=/srv/funkwhale/venv/bin/celery \ + --app funkwhale_api.taskapp \ + worker \ + --loglevel INFO \ + --concurrency=${CELERYD_CONCURRENCY} [Install] WantedBy=multi-user.target diff --git a/docs/administrator_documentation/configuration_docs/optimize.md b/docs/administrator_documentation/configuration_docs/optimize.md index eb0d399fa..210683230 100644 --- a/docs/administrator_documentation/configuration_docs/optimize.md +++ b/docs/administrator_documentation/configuration_docs/optimize.md @@ -30,7 +30,12 @@ Celery uses a `prefork` pool by default. This enables the server to process many 2. Add the `--pool=solo` flag to the `ExecStart` line of your unit file. ```{code-block} text - ExecStart=/srv/funkwhale/.local/bin/poetry run celery -A --pool=solo funkwhale_api.taskapp worker -l INFO --concurrency=${CELERYD_CONCURRENCY} + ExecStart=/srv/funkwhale/venv/bin/celery \ + --app funkwhale_api.taskapp \ + --pool solo \ + worker \ + --loglevel INFO \ + --concurrency=${CELERYD_CONCURRENCY} ``` 3. Restart the Celery service. diff --git a/docs/administrator_documentation/installation_docs/debian.md b/docs/administrator_documentation/installation_docs/debian.md index 98a00945b..a3bbb9e31 100644 --- a/docs/administrator_documentation/installation_docs/debian.md +++ b/docs/administrator_documentation/installation_docs/debian.md @@ -122,31 +122,25 @@ Once you've created the directory structure you can download Funkwhale. Funkwhal You're done! These commands put the software in the correct location for Funkwhale to serve them. -## 4. Install Python dependencies +## 4. Install the Funkwhale API -The Funkwhale API is written in Python. You need to install the API's dependencies to run the software. We use [Poetry](https://python-poetry.org) to handle Python dependencies. +The Funkwhale API is written in Python. You need to install the API's package to run the software: -1. Install Poetry. Follow the steps in this wizard to set it up. +1. Setup a Python virtual environment: ```{code-block} sh - curl -sSL https://install.python-poetry.org | python3 - + cd /srv/funkwhale + sudo python3 -m venv venv + sudo venv/bin/pip install --upgrade pip wheel ``` -2. Add Poetry to your `$PATH`. This allows you to use `poetry` commands. +2. Install the Funkwhale API package and dependencies: ```{code-block} sh - export "PATH=$HOME/.local/bin:$PATH" >> ~/.bashrc - echo 'export "PATH=$HOME/.local/bin:$PATH"' >> ~/.bashrc + sudo venv/bin/pip install --editable ./api ``` -3. Set up poetry in your `/srv/funkwhale/api` directory. - - ```{code-block} sh - cd /srv/funkwhale/api - sudo poetry install - ``` - -You're done! Poetry installs all Python dependencies. +You're done! ## 5. Set up your environment file @@ -369,37 +363,31 @@ grep '${' /etc/nginx/sites-enabled/funkwhale.conf To enable your users to connect to your pod securely, you need to set up {abbr}`TLS (Transport Layer Security)`. To do this, we recommend using the script. -1. Log in as the superuser account to run these commands. +1. Create the `/etc/certs` folder to store the certificates. ```{code-block} sh - su + sudo mkdir /etc/certs ``` -2. Create the `/etc/certs` folder to store the certificates. +2. Download and run `acme.sh`. Replace `my@example.com` with your email address. ```{code-block} sh - mkdir /etc/certs + curl https://get.acme.sh | sudo sh -s email=my@example.com ``` -3. Download and run `acme.sh`. Replace `my@example.com` with your email address. +3. Generate a certificate. Replace `example.com` with your Funkwhale pod name. Use `/srv/funkwhale/front` as your web root folder. ```{code-block} sh - curl https://get.acme.sh | sh -s email=my@example.com + sudo acme.sh --issue -d example.com -w /srv/funkwhale/front ``` -4. Generate a certificate. Replace `example.com` with your Funkwhale pod name. Use `/srv/funkwhale/front` as your web root folder. +4. Install the certificate to your Nginx config. Replace `example.com` with your Funkwhale pod name. ```{code-block} sh - acme.sh --issue -d example.com -w /srv/funkwhale/front - ``` - -5. Install the certificate to your Nginx config. Replace `example.com` with your Funkwhale pod name. - - ```{code-block} sh - acme.sh --install-cert -d example.com \ - --key-file /etc/certs/key.pem \ - --fullchain-file /etc/certs/cert.pem \ - --reloadcmd "service nginx force-reload" + sudo acme.sh --install-cert -d example.com \ + --key-file /etc/certs/key.pem \ + --fullchain-file /etc/certs/cert.pem \ + --reloadcmd "service nginx force-reload" ``` That's it! acme.sh renews your certificate every 60 days, so you don't need to about renewing it. diff --git a/docs/administrator_documentation/upgrade_docs/debian.md b/docs/administrator_documentation/upgrade_docs/debian.md index d03c662fe..803bb0a7a 100644 --- a/docs/administrator_documentation/upgrade_docs/debian.md +++ b/docs/administrator_documentation/upgrade_docs/debian.md @@ -2,78 +2,37 @@ If you installed Funkwhale following the [Debian guide](../installation_docs/debian.md), follow these steps to upgrade. -:::{dropdown} Upgrading to a new version of Python -:icon: alert -:color: warning +## Cleanup old funkwhale files -If you upgrade your Python version, you need to update your virtualenv. Python is updated with each new version of Debian. - -To upgrade your virtualenv: - -1. Change to your api directory. - - ```{code-block} sh - cd /srv/funkwhale/api - ``` - -2. Rerun `poetry install` to reinstall your dependencies in a new virtualenv. - - ```{code-block} sh - poetry install - ``` - -::: - -## Download the updated files - -1. SSH into your server. -2. Log in as your `funkwhale` user. - - ```{code-block} sh - su funkwhale - ``` - -3. Navigate to your Funkwhale directory. - - ```{code-block} sh - cd /srv/funkwhale - ``` - -4. Stop the Funkwhale services. +1. Stop the Funkwhale services. ```{code-block} sh sudo systemctl stop funkwhale.target ``` -5. Export the Funkwhale version you want to update to. You'll use this in the rest of the commands in this guide. +2. Navigate to your Funkwhale directory. + + ```{code-block} sh + cd /srv/funkwhale + ``` + +3. Remove the old files. + + ```{code-block} sh + sudo rm -Rf api/* front/* venv + ``` + +## Download Funkwhale + +1. Export the Funkwhale version you want to update to. You'll use this in the rest of the commands in this guide. ```{parsed-literal} export FUNKWHALE_VERSION={sub-ref}`version` ``` -6. Download the API files for your chosen Funkwhale version. +2. Follow the [3. Download Funkwhale](../installation_docs/debian.md#3-download-funkwhale) installation section. - ```{code-block} sh - curl -L -o "api-$FUNKWHALE_VERSION.zip" "https://dev.funkwhale.audio/funkwhale/funkwhale/-/jobs/artifacts/$FUNKWHALE_VERSION/download?job=build_api" - ``` - -7. Extract the downloaded archive to a new directory. - - ```{code-block} sh - unzip "api-$FUNKWHALE_VERSION.zip" -o api_new - ``` - -8. Remove the old `api` directory and move the extracted directory to the `api` directory. - - ```{code-block} sh - rm -rf api/ && mv api_new api - ``` - -9. Remove the downloaded archive file. - - ```{code-block} sh - rm api-$FUNKWHALE_VERSION.zip - ``` +3. Follow the [4. Install the Funkwhale API](../installation_docs/debian.md#4-install-the-funkwhale-api) installation section. ## Update your Funkwhale instance @@ -85,31 +44,19 @@ Once you have downloaded the new files, you can update your Funkwhale instance. sudo api/install_os_dependencies.sh install ``` -2. Enter the `api` directory to run the following commands. +2. Collect the new static files to serve. ```{code-block} sh - cd api + sudo venv/bin/funkwhale-manage collectstatic --no-input ``` -3. Install all Python dependencies using `poetry`. +3. Apply new database migrations. ```{code-block} sh - poetry install + sudo -u funkwhale venv/bin/funkwhale-manage migrate ``` -4. Collect the new static files to serve. - - ```{code-block} sh - poetry run python3 manage.py collectstatic --no-input - ``` - -5. Apply new database migrations. - - ```{code-block} sh - poetry run python3 manage.py migrate - ``` - -6. Restart the Funkwhale services. +4. Restart the Funkwhale services. ```{code-block} sh sudo systemctl start funkwhale.target