-
Notifications
You must be signed in to change notification settings - Fork 2.5k
docs(admin): add Docker/AIO systemd example for the AI worker #15166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 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``. | ||
|
|
||
|
|
||
| Frequently Asked Questions | ||
| -------------------------- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this boot-enabled service path,
After=/Requires=docker.serviceonly orders on the Docker daemon; it does not wait fornextcloud-aio-nextcloudto be running, while Docker documents thatdocker execruns 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 usingRestart=alwaysplusStartLimitBurst=10/StartLimitInterval=60and 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 👍 / 👎.