-
Notifications
You must be signed in to change notification settings - Fork 0
[INT-200] Check database connection on startup and on /healthz
endpoint
#167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…oint for monitoring
03bb374
to
18be8a3
Compare
Deployed a preview of this PR to https://pr-167-internal.dev.ystv.co.uk |
1 similar comment
Deployed a preview of this PR to https://pr-167-internal.dev.ystv.co.uk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not against it going in now in its current state, but some things for your consideration.
console.error( | ||
`Database connection attempt ${connectionAttempts} failed, retrying...`, | ||
); | ||
await sleep(5000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we bail immediately and not do the whole retry loop / is this delaying the inevitable? Would also simplify this code substantially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reasoning was just to give it a bit of time to get started so it wouldn't just fail instantly and keep getting redeployed if it had an issue on the first connection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly? But in my head that'd only be the case if the database server is the one that's taking a while to start, which it should almost never be in production (the Prisma connection should block if it isn't ready yet), so we'd want to fail fast if something is up with the DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's within 15 seconds, it's not going to cause a massive issue I don't think
Do database connection monitoring slightly better