-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: graceful shutdown and systemd socket activation in adapter-node #11653
feat: graceful shutdown and systemd socket activation in adapter-node #11653
Conversation
🦋 Changeset detectedLatest commit: d8c8a90 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
LGTM but I had one question
Co-authored-by: Conduitry <git@chor.date>
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.
Thank you for your patience during the protracted review process - let's ship it!
I'm having issues with this - in particular when connecting to a database (mongodb). Out of the box it works fine via "npm run dev", but hangs if I build with adapter-node and run with node.
Maybe I'm doing something dumb, but if there some best practice here ? |
Let's please keep the conversation about this in one thread. I've already replied in the other thread and I saw your follow up comment but it can take a few days for me to get back. You can also ask on the Svelte Discord server and ping me there |
Just in case others come across this, here's the other thread: #9540 (comment) |
Closes #10134
Closes #9540
This is an alternative PR to #10977 that addresses all the points mentioned there, mainly:
IDLE_TIMEOUT
It also gracefully shuts down the app by default. A new
SHUTDOWN_TIMEOUT
environment variable controls how long the app should wait for all remaining requests to finish before the server is forcibly closed.If you are on Linux or have access to a Linux server you can try this out yourself by installing the adapter into a new/existing SvelteKit project (requires npm, pnpm doesn't work) using:
Then create a service and socket unit:
Reload the daemon:
Start the socket:
Navigate to
localhost:3000
. The app should then start as soon as the first request is made. IfIDLE_TIMEOUT
is set it will automatically terminate the app after being inactive forIDLE_TIMEOUT
seconds. You can verify this behavior by following the logs usingsudo journalctl -u myapp.service -f
.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits