Skip to content
Syno Package Land
Language: English

Background jobs

The jobs capability adds a persistent queue and one background worker. A signed-in user picks a file; the app reads it once with that session and keeps a private copy in the package’s data folder, which the worker processes after sign-out into a SHA-256 digest. A job never writes to the user’s folders; that needs Delegate.

Terminal window
synopkgland init -t native-go --with jobs my-jobs

For an existing project, run synopkgland add jobs. Both write:

capabilities:
jobs: true

jobs: true is the same as jobs: { worker: sha256-v1 }; no other worker name is accepted. delegate also turns jobs on.

CombinationResult
With daemonCAPABILITY_COMBINATION_INVALID unless delegate uses lifetime: until-revoked
With a binary backendCAPABILITY_UNSUPPORTED

The Vue UI adds a Background jobs page; a plain UI has none. armv7 builds are unverified (Platforms).

The page lets a user pick a file, submit, watch, cancel and see the result; your code calls the same methods through ctx.call. All need a signed-in user and run as the package account without credentials. bg.browse lists files the user may pick, without files.

MethodParamsResult
bg.status{}Limits, counts
bg.jobs.submit{ key, folder, relative }{ job, duplicate }
bg.jobs.list{}{ jobs }, newest first
bg.jobs.get, bg.jobs.cancel{ id }{ job }
bg.jobs.result{ id }{ job, result } or not_ready
const key = crypto.randomUUID()
const { job } = await ctx.call<{ job: { id: string; state: string } }>('bg.jobs.submit', {
key,
folder: '/home',
relative: 'report.txt',
})
const { result } = await ctx.call<{ result: { sha256: string; bytes: number } }>('bg.jobs.result', { id: job.id })
  • key is 1 to 64 letters, digits, dots, underscores and hyphens; reusing it returns the same job with duplicate: true, so retries are safe; keys are per owner. folder is a File Station path; relative a file below it.
  • The result is JSON, not a file: { jobId, worker, workerRevision, algorithm: "sha256", sha256, bytes, inputDigest, name }.
  • A job moves through queued and running, then ends as succeeded, failed, canceled or interrupted; one running when the worker stops is interrupted and is never replayed. Only bg.jobs.cancel cancels it.

After an import, the owner can schedule that copy. The app pins the bytes and digest and never reads the NAS file again, so later source changes do not matter.

MethodParams and access
bg.schedules.list{}; owners see their own, administrators all
bg.schedules.create{ key, jobId, intervalSeconds, consent: true }; source-job owner
bg.schedules.disable, bg.schedules.delete{ id }; owner or administrator
bg.schedules.enable{ id, consent: true }; administrators only
  • intervalSeconds is 3600, 86400 or 604800; consent must be true or the call fails with bad_request. jobId must be your own job with succeeded; an unfinished job, a scheduled run or a gone copy returns input-unavailable.
  • The pin counts toward your 1 MiB and the 16 MiB package limit; scheduled runs leave 4 queue slots for manual jobs. Late ticks are not made up: a schedule is not exact-time or exactly-once.

An owner is a DSM user name together with the numeric UID that DSM resolves for it.

  • Ordinary users list, read, cancel and get their own jobs only; a missing job ID and another owner’s job both return not_found.
  • An administrator sees and cancels all jobs; bg.jobs.purge ({ owner: { user, uid } }) removes one owner’s jobs and is administrator-only.
  • If DSM cannot resolve the UID, the call fails with identity_unavailable; for administrators this affects only submit and schedule create. A recreated account with a new UID cannot reach earlier jobs.
ItemLimit
Jobs running at once / queued1 / 16
Input file512 KiB; 60 seconds per job
Total private copies and results / pending jobs per owner16 MiB / 2 jobs
Private data per owner1 MiB, plus 512 bytes per kept result
Finished jobs / schedules per package64 / 8

The data lives in the package’s app data folder and survives stop and uninstall; see Data and removal.

See Errors for every code.

CodeCause and fix
session_required, dsm_session_requiredNo signed-in user or DSM session. Sign in again; with standalone login the call needs the DSM id cookie
limit-exceeded, queue-fullThe file is over 512 KiB, or 16 jobs are queued. Use a smaller file, or wait
quota-exceeded, owner-queue-full, owner-quota-exceeded16 MiB, 2 pending jobs or 1 MiB of data. Wait, cancel, or ask an administrator
not_found, not_ready, conflictAnother owner’s job, no result yet, or a reused key. Refresh, wait, or new key
schedule-full, input-unavailable8 schedules, or the kept copy is gone. Delete one, or import again
identity_unavailableDSM could not resolve the UID. Retry; check the DSM account
jobs_busy, admin_requiredThe job store was locked over 5 seconds, or the method is administrator-only