Merge pull request #3479 from omnivore-app/fix/queue-processor-lifecycle-hook

Implement a lifecycle hook for queue processor so it can shut down gracefully
This commit is contained in:
Jackson Harper 2024-02-01 17:01:11 +08:00 committed by GitHub
commit 7f4f7c6a80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -142,6 +142,12 @@ const main = async () => {
// respond healthy to auto-scaler.
app.get('/_ah/health', (req, res) => res.sendStatus(200))
app.get('/lifecyle/prestop', async (req, res) => {
logger.info('prestop lifecycle hook called.')
await worker.close()
res.sendStatus(200)
})
app.get('/metrics', async (_, res) => {
const queue = await getBackendQueue()
if (!queue) {