gornostay25 / svelte-adapter-bun

A SvelteKit adapter for Bun
MIT License
537 stars 34 forks source link

Add support for graceful shutdown on SIGINT and SIGTERM #52

Open RFHold opened 8 months ago

RFHold commented 8 months ago

Currently on Mac and Docker, the only way for me to shut down the running server is to manually kill the process. This is not ideal for production environments. This feature was added to adapter-node with this issue https://github.com/sveltejs/kit/issues/9540

gornostay25 commented 8 months ago

@RFHold yeah its a good point

AmrSaber commented 1 month ago

This is causing me problems with docker, as the container will totally ignore docker's stop signal. Docker always sends a SIGINT signal then wait 30s before killing the container.

This causes me 2 issues:

  1. Stopping the container is slow, as I always need to wait 30s until docker kills the container.
  2. I don't get any graceful shutdown, as any in-progress request is killed when the process itself is killed.

I created PR #69 to handle system signals, @gornostay25 please review and merge.

Edit: For anyone with the same problem, I currently solve this problem with STOPSIGNAL SIGKILL at the end of my Dockerfile, this tells docker to send a SIGKILL directly and skip the 30s wait.