fffleet-worker 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,6 +22,7 @@ docker run -p 5100:5100 -e FFFLEET_TOKEN=secret ghcr.io/jsilvanus/fffleet-worker
22
22
  | `FFFLEET_HEARTBEAT_MS` | `5000` | |
23
23
  | `FFFLEET_WORK_DIR` | `$TMPDIR/fffleet` | Scratch space for staged inputs and outputs. |
24
24
  | `FFFLEET_CACHE_DIR` | | Keep staged `s3://` and `http(s)://` inputs here between jobs (hard-linked, checked against the object's ETag). Off when unset. |
25
+ | `FFFLEET_EXECUTORS` | | Comma-separated modules (package names or paths) that add job types. Each default-exports `{ type, run(spec, runtime) }` or an array of them. The worker then claims `type:<type>`. |
25
26
  | `FFFLEET_CACHE_MAX_SIZE` | `20GB` | Least recently used inputs are removed above this. |
26
27
  | `FFMPEG_PATH` | `ffmpeg` | |
27
28
  | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` | | Enable `s3://` inputs and outputs and the `scheme:s3` capability. Also `AWS_SESSION_TOKEN`, `AWS_REGION`. |
@@ -1,11 +1,26 @@
1
1
  #!/usr/bin/env node
2
+ import { isAbsolute, resolve } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
2
4
  import { s3ConfigFromEnv } from 'fffleet';
3
5
  import { createWorker } from '../src/worker.js';
4
6
 
5
7
  const env = process.env;
6
8
  const list = v => (v ? v.split(',').map(s => s.trim()).filter(Boolean) : []);
7
9
 
10
+ // Extra job types: FFFLEET_EXECUTORS lists modules (package names or paths) that default-export
11
+ // { type, run(spec, runtime) } or an array of them. Workers with them claim type:<type>.
12
+ const executors = {};
13
+ for (const ref of list(env.FFFLEET_EXECUTORS)) {
14
+ const specifier = ref.startsWith('.') || isAbsolute(ref) ? pathToFileURL(resolve(ref)).href : ref;
15
+ const mod = await import(specifier);
16
+ for (const e of [mod.default].flat()) {
17
+ if (!e || typeof e.type !== 'string' || typeof e.run !== 'function') throw new Error(`${ref}: default export must be { type, run } or an array of them`);
18
+ executors[e.type] = e.run;
19
+ }
20
+ }
21
+
8
22
  const worker = createWorker({
23
+ executors,
9
24
  id: env.FFFLEET_WORKER_ID || undefined,
10
25
  port: Number(env.PORT ?? 5100),
11
26
  host: env.HOST ?? '0.0.0.0',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fffleet-worker",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "fffleet worker daemon: runs ffmpeg jobs and serves the fffleet job API",
5
5
  "type": "module",
6
6
  "main": "./src/worker.js",
@@ -21,7 +21,7 @@
21
21
  "test": "node --test test/*.test.js"
22
22
  },
23
23
  "dependencies": {
24
- "fffleet": "^1.0.0"
24
+ "fffleet": "^2.0.0"
25
25
  },
26
26
  "keywords": [
27
27
  "ffmpeg",
package/src/worker.js CHANGED
@@ -110,6 +110,8 @@ export function createWorker({
110
110
  list: () => manager.list(),
111
111
  cancel: jobId => manager.cancel(jobId),
112
112
  writeStdin: (jobId, data) => manager.writeStdin(jobId, data),
113
+ closeStdin: jobId => manager.closeStdin(jobId),
114
+ openStdout: jobId => manager.openStdout(jobId),
113
115
  subscribe: (jobId, after, fn) => manager.subscribe(jobId, after, fn),
114
116
  capabilities: () => ({ id, version: VERSION, kinds: manager.kinds, slots: manager.stats().pools, queued: manager.stats().queued, capabilities }),
115
117
  };