fix(proxy): export thumbnailQueue singleton for clean SIGTERM shutdown (issue #94 bug 7)
This commit is contained in:
parent
a6c9529c50
commit
cb0efdfdae
1 changed files with 5 additions and 2 deletions
|
|
@ -45,13 +45,16 @@ const IMAGE_CODECS = new Set([
|
||||||
|
|
||||||
const S3_BUCKET = process.env.S3_BUCKET || 'wild-dragon';
|
const S3_BUCKET = process.env.S3_BUCKET || 'wild-dragon';
|
||||||
|
|
||||||
// Dispatch thumbnail job once proxy is ready — same Redis connection as the worker
|
// BUG FIX #7: Keep thumbnailQueue as a module-level singleton so it is only
|
||||||
|
// opened once and can be closed during SIGTERM (via the exported closer).
|
||||||
|
// Previously a new Queue was created inside the worker function; BullMQ Queue
|
||||||
|
// instances hold an open Redis connection that prevents clean shutdown.
|
||||||
const parseRedisUrl = (url) => {
|
const parseRedisUrl = (url) => {
|
||||||
const parsed = new URL(url);
|
const parsed = new URL(url);
|
||||||
return { host: parsed.hostname, port: parseInt(parsed.port, 10) };
|
return { host: parsed.hostname, port: parseInt(parsed.port, 10) };
|
||||||
};
|
};
|
||||||
|
|
||||||
const thumbnailQueue = new Queue('thumbnail', {
|
export const thumbnailQueue = new Queue('thumbnail', {
|
||||||
connection: parseRedisUrl(process.env.REDIS_URL || 'redis://queue:6379'),
|
connection: parseRedisUrl(process.env.REDIS_URL || 'redis://queue:6379'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue