Implement a lifecycle hook for queue processor so it can shut down gracefully

This commit is contained in:
Jackson Harper
2024-02-01 16:43:57 +08:00
parent f03b7182b3
commit 0e9e331e18

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) {