supabase / postgres-meta

A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries
https://supabase.com
Apache License 2.0
941 stars 126 forks source link

feat: implement graceful shutdown on sigterm #728

Closed sweatybridge closed 9 months ago

sweatybridge commented 9 months ago

What kind of change does this PR introduce?

Bug fix https://github.com/supabase/postgres-meta/issues/663

What is the new behavior?

Uses closes-with-grace package from fastify authors. Shuts down the server on the following events

Additional context

Tested with docker-compose.yml

$ docker compose up --build
...
[+] Running 1/1
 ✔ Container postgres-meta-meta-1  Recreated                                           0.1s 
Attaching to postgres-meta-meta-1
postgres-meta-meta-1  | (node:1) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
postgres-meta-meta-1  | (Use `node --trace-warnings ...` to show where the warning was created)
postgres-meta-meta-1  | {"level":"info","time":"2024-02-21T10:03:46.750Z","pid":1,"hostname":"dce592e0de3a","msg":"Server listening at http://0.0.0.0:8080"}
postgres-meta-meta-1  | {"level":"info","time":"2024-02-21T10:03:46.757Z","pid":1,"hostname":"dce592e0de3a","msg":"Server listening at http://0.0.0.0:8081"}
^CGracefully stopping... (press Ctrl+C again to force)
Aborting on container exit...
[+] Running 1/1
 ✔ Container postgres-meta-meta-1  Stopped                                             0.2s 
canceled
soedirgo commented 9 months ago

Sweet! Would've thought this is built-in