import QueueWorkBase from '@adonisjs/queue/commands/queue_work' /** * Local shadow of @adonisjs/queue's queue:work command. * * Upstream declares staysAlive: true but never calls app.terminate() after * the worker drains on SIGINT, so provider-held handles (Lucid pool, logger, * etc.) keep the event loop alive and the process hangs until a second Ctrl-C * forces Node's default-action exit. We wait for super.run() to finish * (boringnode's shutdown handler has already drained the pool by then), then * terminate the app and exit explicitly. */ export default class QueueWork extends QueueWorkBase { async run() { try { await super.run() } catch (error) { this.logger.error(error instanceof Error ? error.message : String(error)) this.exitCode = 1 } try { await this.app.terminate() } catch { /* ignore */ } process.exit(this.exitCode ?? 0) } }