diff --git a/admin_manual/ai/overview.rst b/admin_manual/ai/overview.rst index cb59310b04a..944b6803b0c 100644 --- a/admin_manual/ai/overview.rst +++ b/admin_manual/ai/overview.rst @@ -416,6 +416,39 @@ The complete logs of the workers can be checked with (replace 1 with the worker journalctl -xeu nextcloud-ai-worker@1.service -f +If your Nextcloud runs inside a Docker container (for example with Nextcloud AIO), the worker has to run +*inside* the container. Make the service unit shown above wait for Docker by extending its ``[Unit]`` +section: + +.. code-block:: ini + + [Unit] + Description=Nextcloud AI worker %i + After=network.target docker.service + Requires=docker.service + +and call ``occ`` through ``docker exec`` in ``taskprocessing.sh`` instead of running it locally. The +``[Unit]`` ordering above only waits for the Docker daemon, not for the ``nextcloud-aio-nextcloud`` +container, so the script waits until that container reports healthy before running ``occ`` (the AIO image +ships a healthcheck for php-fpm and the database). Without this wait the worker would exit immediately +after a host reboot and, with ``Restart=always``, hit systemd's start-rate limit and stay down until a +manual reset: + +.. code-block:: bash + + #!/bin/sh + echo "Starting Nextcloud AI Worker $1" + i=0 + until [ "$(docker inspect -f '{{.State.Health.Status}}' nextcloud-aio-nextcloud 2>/dev/null)" = healthy ]; do + i=$((i + 1)) + [ "$i" -ge 60 ] && echo "nextcloud-aio-nextcloud not healthy after 5 min" && exit 1 + sleep 5 + done + docker exec -i nextcloud-aio-nextcloud sudo -E -u www-data php occ taskprocessing:worker -v -t 60 + +Use ``docker exec -i`` without ``-t``: systemd does not allocate a pseudo-TTY, so adding ``-t`` makes the +command fail with ``the input device is not a TTY``. + Frequently Asked Questions --------------------------