You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most AI tasks will be run as part of the background job system in Nextcloud which only runs jobs every 5 minutes by default. To pick up scheduled jobs faster you can set up background job workers that process AI tasks as soon as they are scheduled. If the PHP code or the Nextcloud settings values are changed while a worker is running, those changes won’t be effective inside the runner. For that reason, the worker needs to be restarted regularly. It is done with a timeout of N seconds which means any changes to the settings or the code will be picked up after N seconds (worst case scenario). This timeout does not, in any way, affect the processing or the timeout of the AI tasks.
#!/bin/bashecho"Starting Nextcloud AI Worker $1"# Function to attempt starting the workerstart_worker() {
echo"Attempting to start Nextcloud AI Worker $1..."# Run the worker inside the container (60 seconds for task execution)
docker exec --user www-data nextcloud-aio-nextcloud php occ background-job:worker -t 60 'OC\TaskProcessing\SynchronousBackgroundJob'# Capture the exit status of the docker exec command
exit_code=$?# Check if the worker ran successfullyif [ $exit_code-eq 0 ];thenecho"Worker completed successfully."return 0 # Successelseecho"Worker failed to start or complete with exit code $exit_code."return 1 # Failurefi
}
# Loop to start the worker and retry if it failswhiletrue;do# Check if the container is runningif! docker ps --format "{{.Names}}"| grep -q "^nextcloud-aio-nextcloud$";thenecho"Nextcloud container is not running. Waiting 60 seconds before next attempt."
sleep 60 # If the container isn't running, wait for 60 secondscontinue# Skip to the next iterationfi# Start the worker
start_worker
# Check if the worker succeeded or failedif [ $?-eq 1 ];then# If failed, wait 30 seconds (or adjust as needed) to avoid rapid retriesecho"Worker failed. Waiting 30 seconds before retrying..."
sleep 30
fidone
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Most AI tasks will be run as part of the background job system in Nextcloud which only runs jobs every 5 minutes by default. To pick up scheduled jobs faster you can set up background job workers that process AI tasks as soon as they are scheduled. If the PHP code or the Nextcloud settings values are changed while a worker is running, those changes won’t be effective inside the runner. For that reason, the worker needs to be restarted regularly. It is done with a timeout of N seconds which means any changes to the settings or the code will be picked up after N seconds (worst case scenario). This timeout does not, in any way, affect the processing or the timeout of the AI tasks.
Use these instructions https://docs.nextcloud.com/server/latest/admin_manual/ai/overview.html#systemd-service but in step 2, use the following script:
Beta Was this translation helpful? Give feedback.
All reactions