dont working onClose hooks #4458
-
import fp from 'fastify-plugin'
import Redis from 'ioredis'
import waitOn from 'wait-on'
import { database } from '../config'
declare module 'fastify' {
interface FastifyInstance {
redis: Redis
}
}
export const redisPlugin = fp(async (f) => {
const logger = f.log.child({ plugin: 'redis' })
logger.info('Wait for redis connection.')
// wait for db to be alive
await waitOn({
resources: [`tcp:${database.redisHOST}:${database.redisPORT}`],
timeout: 30000,
})
logger.info('redis is started. Connecting to it.')
const redis = new Redis(database.redisURL)
f.decorate('redis', redis)
f.addHook('onClose', async () => {
redis.disconnect()
})
}) Node: v18.12.1 |
Beta Was this translation helpful? Give feedback.
Answered by
mcollina
Dec 3, 2022
Replies: 3 comments 6 replies
-
There is no onClose-Hook. |
Beta Was this translation helpful? Give feedback.
2 replies
-
What is not working? |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Fdawgs
-
Maybe ctrl+c does not send SIGTERM or SIGKILL? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is not working?