- seed_nodes (hashed bearer tokens) and seed_ranges (planned ranges with lease, resume point and counts); migration …140. - SeedOrchestrator: lease (oldest plan first, FOR UPDATE SKIP LOCKED; a lease without a batch for 15 min passes to the next node and resumes at next_id), batch (stores files and fragments, moves next_id), finish, release, plan (from below live indexing / the backfill / earlier plans down to N days back; takes over the group's backfill), status. - Seed API under /api/v1/seed (lease, ranges/:id/batches|done|release, status) behind a node-token middleware; JSON bodies up to 64 MB after gzip. - seed:node runs a node: no database or Redis, outgoing HTTPS only, N connections, gzip batches, retries for network errors and 5xx, drops a range on 409, gives its ranges back on SIGTERM. seed-node/ has a compose file that builds the image from this repository. - seed:token, seed:plan, seed:status for the operator. Header parsing moved to lib/ingest and the range loop to lib/seed/runner, shared by seed:range and seed:node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { BaseCommand, args, flags } from '@adonisjs/core/ace'
|
|
import { CommandOptions } from '@adonisjs/core/types/ace'
|
|
import db from '@adonisjs/lucid/services/db'
|
|
import SeedOrchestrator from '#services/SeedOrchestrator'
|
|
|
|
/**
|
|
* Creates a seeding node, or gives it a new token (the old one stops
|
|
* working), and prints the token once (CONCEPT.md D38).
|
|
*
|
|
* node ace seed:token hetzner-1
|
|
* node ace seed:token hetzner-1 --disable
|
|
*/
|
|
export default class SeedToken extends BaseCommand {
|
|
public static commandName = 'seed:token'
|
|
public static description = 'Creates a seeding node or replaces its token; prints the token once.'
|
|
|
|
public static options: CommandOptions = {
|
|
startApp: true,
|
|
}
|
|
|
|
@args.string({ description: 'Node name' })
|
|
declare name: string
|
|
|
|
@flags.boolean({ description: 'Disable the node instead (its leases pass to others after they expire)' })
|
|
declare disable: boolean
|
|
|
|
public async run() {
|
|
if (this.disable) {
|
|
const n = await db.from('seed_nodes').where('name', this.name).update({ disabled: true })
|
|
this.logger.info(n ? `${this.name}: disabled.` : `${this.name}: no such node.`)
|
|
return
|
|
}
|
|
const token = await SeedOrchestrator.issueToken(this.name)
|
|
this.logger.info(`${this.name}: token (shown once, keep it on the node only):`)
|
|
console.log(token)
|
|
}
|
|
}
|