immich icon indicating copy to clipboard operation
immich copied to clipboard

feat(cli): jobs commands

Open l0ll098 opened this issue 4 months ago • 2 comments

Description

Hi, this PR adds a couple of commands in the Immich CLI, to allow users to interact with background jobs directly from within the terminal.

It adds a new jobs command with these subcommands:

  • pause: it stops executions of a given job
  • resume: resumes execution of the given job
  • run: schedules execution of a job instance, given its' name
  • status: prints the status of either all jobs, or of a specific job

With the run command is it also possible to run that job only on:

  • assets that were not previosuly processed (default),
  • on all assets. In this case the force parameter in the corresponding DTO is set to true
  • on all assets, while preserving outputs of previous executions of this job

Also, I've edited documentation pages to describe these new features.

How Has This Been Tested?

This has been manually tested with several combinations of the jobs run, jobs status, jobs pause, and jobs resume commands. Also, since these commands call the Jobs endpoints exposed by Immich, we can check how these affected the system also using the Immich UI.

Output

Usage: immich jobs [options] [command]

Manage background jobs

Options:
  -h, --help                  display help for command

Commands:
  pause [options] <jobName>   Pause executions of all instances of the given job
  resume [options] <jobName>  Resume executions of all instances of the given job
  run [options] <jobName>     Start a specific job
  status [options] [jobName]  Get the status of all jobs or the status of a specific job
  help [command]              display help for command

Status of all jobs

 node ./cli/dist/index.js jobs status
┌─────────┬────────────────────────────┬───────────────┬───────────────┬─────────────┬────────────────┬─────────────┬──────────────┬──────────────┬─────────────┐
│ (index) │            name            │ isQueueActive │ isQueuePaused │ Active Jobs │ Completed Jobs │ Failed Jobs │ Delayed Jobs │ Waiting Jobs │ Paused Jobs │
├─────────┼────────────────────────────┼───────────────┼───────────────┼─────────────┼────────────────┼─────────────┼──────────────┼──────────────┼─────────────┤
│    0    │   'thumbnailGeneration'    │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    1    │    'metadataExtraction'    │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    2    │     'videoConversion'      │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    3    │       'smartSearch'        │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    4    │ 'storageTemplateMigration' │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    5    │        'migration'         │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    6    │      'backgroundTask'      │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    7    │          'search'          │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    8    │    'duplicateDetection'    │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│    9    │      'faceDetection'       │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│   10    │    'facialRecognition'     │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│   11    │         'sidecar'          │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│   12    │         'library'          │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│   13    │      'notifications'       │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
│   14    │      'backupDatabase'      │     false     │     false     │      0      │       0        │      0      │      0       │      0       │      0      │
└─────────┴────────────────────────────┴───────────────┴───────────────┴─────────────┴────────────────┴─────────────┴──────────────┴──────────────┴─────────────┘

Checklist:

  • [x] I have performed a self-review of my own code
  • [x] I have made corresponding changes to the documentation if applicable
  • [x] I have no unrelated changes in the PR.
  • [x] I have confirmed that any new dependencies are strictly necessary.
  • [x] I have written tests for new code (if applicable)
  • [x] I have followed naming conventions/patterns in the surrounding code
  • [x] All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • [x] All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

l0ll098 avatar Jun 15 '25 08:06 l0ll098