Skip to content

bun app quits before sandboxed processor is processed #39

@arthurvanl

Description

@arthurvanl

Problem

So it seems there is an easy fix but I just did not know how to:

const worker = new SandboxedWorker<EmailJob>('emails', {
  processor: './processor.ts',
  concurrency: 5,
  heartbeatInterval: 5000,
});
process.on('SIGINT', async () => {
    console.log('Shutting down...');

    while(true) {
        await sleep(1000);

        if(worker.getStats().busy === 0) { break; }

    }
    await worker.stop();
  shutdownManager();
  process.exit(0);
});

this fixes that running jobs are still processed fully

Proposed solution

Update the page: https://bunqueue.dev/guide/use-cases/#graceful-shutdown-pattern

Alternatives considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions