Skip to content

Commit

Permalink
Merge pull request #885 from supabase/close-both-apps
Browse files Browse the repository at this point in the history
fix: Close both apps to allow for process restart
  • Loading branch information
kamilogorek authored Feb 5, 2025
2 parents 8ad7e24 + 38e265d commit fc69684
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/server/admin-app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { fastify, FastifyInstance, FastifyServerOptions } from 'fastify'

import FastifyMetrics from 'fastify-metrics'
import fastifyMetrics from 'fastify-metrics'

export function build(opts: FastifyServerOptions = {}): FastifyInstance {
const app = fastify(opts)
// @ts-ignore fastify-metrics doesn't work with NodeNext resolution
app.register(FastifyMetrics, {
app.register(fastifyMetrics.default, {
endpoint: '/metrics',
routeMetrics: { enabled: false },
})
Expand Down
6 changes: 6 additions & 0 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ if (EXPORT_DOCS) {
app.log.error(err)
}
await app.close()
await adminApp.close()
})
app.addHook('onClose', async () => {
closeListeners.uninstall()
await adminApp.close()
})
adminApp.addHook('onClose', async () => {
closeListeners.uninstall()
await app.close()
})

app.listen({ port: PG_META_PORT, host: PG_META_HOST }, (err) => {
Expand Down

0 comments on commit fc69684

Please sign in to comment.