Self-hosted multi-platform broadcast newsroom for activist collectives: publishing pipeline with group approval and DST-proof scheduling, TweetDeck-style column wall with hostile-content-safe rendering, live control room with Auto Director, bridged chat governance with polls and quorum, distributed sandboxed transcode workers, encrypted content-addressed archive, monthly analytics. MIT licensed. See README.md and docs/.
32 lines
1.9 KiB
JavaScript
32 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
'use strict';
|
|
// Uses the same IPC library/protocol as the official runner. Registration secret from stdin.
|
|
const { Client } = require('./runtime/node_modules/@peertube/net-ipc');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const action = process.argv[2];
|
|
const home = process.env.HOME;
|
|
const socket = path.join(home, '.local/share/peertube-runner-nodejs/default/peertube-runner.sock');
|
|
const client = new Client({ path: socket, reconnect: false });
|
|
const deadline = setTimeout(() => { client.destroy(); process.exit(1); }, 15000);
|
|
(async () => {
|
|
try {
|
|
await client.connect();
|
|
let request = { type: action };
|
|
if (action === 'register') {
|
|
const cfg = JSON.parse(fs.readFileSync(process.env.PT_WORKER_CONFIG || '/etc/pt-worker/worker.json'));
|
|
const registrationToken = fs.readFileSync(0, 'utf8').trim();
|
|
if (!registrationToken.startsWith('ptrrt-')) throw new Error('bad token');
|
|
request = { type: 'register', url: cfg.peertube_url, runnerName: cfg.name, registrationToken,
|
|
runnerDescription: 'VOD only; QSV required; admission controlled' };
|
|
} else if (!['list-jobs', 'list-registered', 'graceful-shutdown'].includes(action)) throw new Error('bad action');
|
|
const result = await client.request(request);
|
|
if (!result.success) throw new Error('IPC failed');
|
|
if (action === 'list-jobs') {
|
|
// Drop payloads (can contain URLs); status consumers only need counts.
|
|
console.log(JSON.stringify({ concurrency: result.data.concurrency, active_jobs: result.data.processingJobs.length }));
|
|
} else if (action === 'list-registered') console.log(JSON.stringify(result.data));
|
|
else console.log(JSON.stringify({ success: true }));
|
|
} catch { console.error('Runner IPC failed; inspect local service health'); process.exitCode = 1; }
|
|
finally { clearTimeout(deadline); client.destroy(); }
|
|
})();
|