import { BaseCommand } from '@adonisjs/core/ace' import type { CommandOptions } from '@adonisjs/core/types/ace' import { Prober } from '#services/prober' /** Phase 2's prober (REBUILD.md, part 6): reads the probe queue's articles and stores what they show. */ export default class ProbeRun extends BaseCommand { static commandName = 'probe:run' static description = "Reads the probe queue's articles (PROBE_CONNECTIONS) and stores what they show" static options: CommandOptions = { startApp: true, staysAlive: true } async run() { const prober = new Prober() let done: () => void const finished = new Promise((resolve) => (done = resolve)) this.app.terminating(async () => { this.logger.info('Stopping: finishing the articles in flight.') prober.stop() await finished }) await prober.run() this.logger.info('Prober stopped.') done!() await this.terminate() } }