Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions admin_manual/ai/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +427 to +428

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for the Nextcloud container before starting workers

In this boot-enabled service path, After=/Requires=docker.service only orders on the Docker daemon; it does not wait for nextcloud-aio-nextcloud to be running, while Docker documents that docker exec runs a command in a running container. If AIO is still stopped or starting after Docker becomes active, for example after a host reboot or container update, line 436 exits immediately; with the unit above using Restart=always plus StartLimitBurst=10/StartLimitInterval=60 and systemd restarts being subject to start-rate limiting, the worker can hit the limit and remain down until manually reset. Please wait for the container or its health check, or add a restart delay, before enabling this variant.

Useful? React with 👍 / 👎.


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:
Comment on lines +430 to +435

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

maybe it hits even in maintenance mode?
trap 'sleep 10' EXIT can be added at the start of the script after the shebang so the script does not hit the systemd start limit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you'd be kind enough, this would also make sense in the script that runs in non-AIO environment above.


.. 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle Docker containers without health checks

Because this section is introduced for any Nextcloud Docker container, not just AIO, this wait loop makes the documented systemd unit unusable for the official/community nextcloud images unless the admin adds their own HEALTHCHECK. Docker's HEALTHCHECK docs describe health status as coming from that instruction, and the current official nextcloud Dockerfile has no HEALTHCHECK, so docker inspect -f '{{.State.Health.Status}}' ... produces no healthy value with stderr suppressed; the loop times out after five minutes and occ is never started even though the container is running. Either scope this snippet to AIO only or fall back to .State.Running when .State.Health is absent.

Useful? React with 👍 / 👎.

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``.
Comment on lines +449 to +450

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-t works with normal docker containers, maybe this is the case with AIO containers.
would you mind modifying the command in the "Screen or tmux session" section as well for the AIO part? To remove the -t.



Frequently Asked Questions
--------------------------
Expand Down