From 5b11ae0caf7131b6e8dd0b3be5f8f7622a17df16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sat, 15 Nov 2025 03:38:49 +0100 Subject: [PATCH] nc-nextcloud.sh, ncp-provisioning.sh: Implement nextcloud service workers --- bin/ncp-provisioning.sh | 8 ++++++++ bin/ncp/CONFIG/nc-nextcloud.sh | 19 +++++++++++++++++++ updates/1.56.0.sh | 23 +++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/bin/ncp-provisioning.sh b/bin/ncp-provisioning.sh index b4b7400c..82c7deae 100644 --- a/bin/ncp-provisioning.sh +++ b/bin/ncp-provisioning.sh @@ -82,5 +82,13 @@ EOF cat /usr/local/etc/instance.cfg } +systemctl is-enabled -q nextcloud-ai-worker@1.service || { + max="$(nproc || echo '2')" + max="$((max-1))" + for i in $(seq 1 "$max") + do + systemctl enable --now "nextcloud-ai-worker@${i}.service" + done +} exit 0 diff --git a/bin/ncp/CONFIG/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh index 70732b5e..5582dfee 100644 --- a/bin/ncp/CONFIG/nc-nextcloud.sh +++ b/bin/ncp/CONFIG/nc-nextcloud.sh @@ -83,6 +83,25 @@ EOF update-rc.d redis-server enable clear_opcache + # NC service workers + cat > /etc/systemd/system/nextcloud-ai-worker@.service <<'EOF' +[Unit] +Description=Nextcloud AI worker %i +After=network.target + +[Service] +ExecStart=php occ background-job:worker -t 60 'OC\\TaskProcessing\\SynchronousBackgroundJob' +Restart=always +StartLimitInterval=60 +StartLimitBurst=10 +WorkingDirectory=/var/www/nextcloud +User=www-data + +[Install] +WantedBy=multi-user.target +EOF + + # service to randomize passwords on first boot mkdir -p /usr/lib/systemd/system cat > /usr/lib/systemd/system/nc-provisioning.service <<'EOF' diff --git a/updates/1.56.0.sh b/updates/1.56.0.sh index 6466a2d9..d5224319 100644 --- a/updates/1.56.0.sh +++ b/updates/1.56.0.sh @@ -5,4 +5,27 @@ then ncc app:disable app_api fi +cat > /etc/systemd/system/nextcloud-ai-worker@.service <<'EOF' +[Unit] +Description=Nextcloud AI worker %i +After=network.target + +[Service] +ExecStart=php occ background-job:worker -t 60 'OC\\TaskProcessing\\SynchronousBackgroundJob' +Restart=always +StartLimitInterval=60 +StartLimitBurst=10 +WorkingDirectory=/var/www/nextcloud +User=www-data + +[Install] +WantedBy=multi-user.target +EOF +max="$(nproc || echo '2')" +max="$((max-1))" +for i in $(seq 1 "$max") +do + systemctl enable --now "nextcloud-ai-worker@${i}.service" +done + exit 0 \ No newline at end of file