Skip to content

docs(admin): add Docker/AIO systemd example for the AI worker#15166

Open
sanzakicesarr wants to merge 3 commits into
nextcloud:masterfrom
sanzakicesarr:docs/ai-worker-docker-systemd
Open

docs(admin): add Docker/AIO systemd example for the AI worker#15166
sanzakicesarr wants to merge 3 commits into
nextcloud:masterfrom
sanzakicesarr:docs/ai-worker-docker-systemd

Conversation

@sanzakicesarr

@sanzakicesarr sanzakicesarr commented Jun 16, 2026

Copy link
Copy Markdown

The Systemd service section of the AI overview only documented running the task-processing worker on bare
metal. When Nextcloud runs inside a Docker container (for example Nextcloud AIO) the service has to (a) wait for
Docker and (b) call occ inside the container via docker exec. This adds that variant right after the existing
systemd example:

  • extend the [Unit] section with After=network.target docker.service and Requires=docker.service, so the
    worker only starts once Docker is up;
  • a taskprocessing.sh that runs
    docker exec -i nextcloud-aio-nextcloud sudo -E -u www-data php occ taskprocessing:worker -v -t 60.

Using docker exec -i without -t is deliberate: systemd provides no pseudo-TTY, so -t would fail with
the input device is not a TTY.

Notes for review:

  • The command mirrors the existing AIO docker exec example already in the Screen or tmux session section
    (same container name, user and command) and uses the current taskprocessing:worker command — the page
    documents (.. versionchanged:: 32.0.7) that this replaced background-job:worker.
  • Kept as plain prose + code blocks to match that existing Docker example on the same page, rather than a
    .. note::.
  • The two new code blocks carry explicit ini / bash language tags per the style guide ("always specify the
    language"); the surrounding pre-existing blocks are left untouched to keep the change focused.

✅ Resolves

🖼️ Screenshots

Rendered Systemd service section, new Docker/AIO variant at the bottom:
pr13075_systemd

✅ Checklist

  • I have built the documentation locally and reviewed the output
  • Screenshots are included for visual changes (screenshot to follow later today)
  • I have not moved or renamed pages (or added a redirect if I did)
  • I have run codespell or similar and addressed any spelling issues

The "Systemd service" section only documented running the AI worker on
bare metal. When Nextcloud runs inside a Docker container (for example
Nextcloud AIO) the service has to wait for Docker and invoke occ inside
the container via docker exec.

Document extending the [Unit] section with a dependency on docker.service
and a taskprocessing.sh that uses "docker exec -i" without -t, since
systemd provides no pseudo-TTY. The command mirrors the existing AIO
docker exec example in the screen/tmux section and uses the current
taskprocessing:worker command.

Signed-off-by: Cesar <275373127+sanzakicesarr@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a12832ec7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +427 to +428
After=network.target docker.service
Requires=docker.service

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 👍 / 👎.

sanzakicesarr and others added 2 commits June 16, 2026 14:09
The Docker/AIO worker variant only ordered the unit on docker.service,
which gates on the Docker daemon, not on the nextcloud-aio-nextcloud
container. After a host reboot or a container update, docker exec could
fire before the container was back, exit non-zero, and with
Restart=always trip systemd's start-rate limit, leaving the worker down
until a manual reset.

Make taskprocessing.sh wait until the container reports healthy (the AIO
image ships a healthcheck for php-fpm and the database) before running
occ, bounded to five minutes so a genuinely missing container still
surfaces as a failure instead of hanging forever.

Signed-off-by: Cesar <275373127+sanzakicesarr@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cdd0997706

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

#!/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 👍 / 👎.

@sanzakicesarr

Copy link
Copy Markdown
Author

Good catch. Requires/After=docker.service only gate on the Docker daemon, not on the
nextcloud-aio-nextcloud container, so after a host reboot or a container update the docker exec
can fire before the container is back, exit non zero, and with Restart=always the unit walks into
the start limit and stays down until a manual reset.

I reworked the worker script to wait for the container to report healthy before running occ. The
AIO nextcloud image ships a healthcheck (php-fpm on 127.0.0.1:9000 plus the database), so healthy
is a real readiness signal rather than just "running", and the wait is bounded at five minutes so a
genuinely missing container still surfaces as a failure instead of hanging forever. Because each
attempt waits instead of exiting instantly, the start limit is never reached on a slow boot. 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion: Add systemd example for AI worker using Docker (docker exec) to documentation

1 participant