-
Notifications
You must be signed in to change notification settings - Fork 348
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
fix-3238 gracefully shutdown server #3239
fix-3238 gracefully shutdown server #3239
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Ignored Deployments
|
@dillonstreator is attempting to deploy a commit to the Medplum Team on Vercel. A member of the Team first needs to authorize it. |
Apply Sweep Rules to your PR?
|
@dillonstreator - Sorry about the build issues... It looks like it's something funky with Coveralls. I have a fix here: #3246 |
@@ -264,6 +265,7 @@ function addDefaults(config: MedplumServerConfig): MedplumServerConfig { | |||
config.botLambdaLayerName = config.botLambdaLayerName || 'medplum-bot-layer'; | |||
config.bcryptHashSalt = config.bcryptHashSalt || 10; | |||
config.bullmq = { removeOnComplete: { count: 1 }, removeOnFail: { count: 1 }, ...config.bullmq }; | |||
config.shutdownTimeoutMilliseconds = config.shutdownTimeoutMilliseconds ?? 30000; |
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.
This is redundant in its current state as the default timeout for http-graceful-shutdown
is already 30 seconds https://github.com/sebhildebrandt/http-graceful-shutdown#options
I can remove, unless we'd like to adjust the default.
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.
30 seconds is appropriate. I don't have strong feelings about whether to be explicit or implicit here.
For my own curiosity, the AWS Fargate Task timeout is also 30 seconds: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_StopTask.html In the common case, server shutdown should be fast (under 1 second). The exceptions being:
Those can take upwards of 30 seconds. Overall, it feels good to be explicit. Thanks @dillonstreator |
packages/server/src/index.ts
Outdated
@@ -22,6 +23,17 @@ export async function main(configName: string): Promise<void> { | |||
const server = app.listen(config.port); | |||
server.keepAliveTimeout = config.keepAliveTimeout ?? 90000; | |||
globalLogger.info('Server started', { port: config.port }); | |||
gracefulShutdown(server, { | |||
timeout: config.shutdownTimeoutMilliseconds, | |||
development: process.env.NODE_ENV !== "production", |
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.
@codyebberson might be nice for the app config to define environment
with an enum.
Maybe a separate issue?
@dillonstreator - Apologies for the inconvenience, but if you rebase & resubmit, the Github Actions problems should be fixed. Or let me know, and we can do it on your behalf. |
4538d06
to
833067c
Compare
All good - I've rebased on |
Blerg, the prettier comment tool doesn't work on forks apparently, sorry about that. There's one prettier error in https://github.com/medplum/medplum/actions/runs/6778421837/job/18429916344?pr=3239 ![]() |
chore(actions): add console output for `prettier-fmt` Actions workflow (#3278) feat(auth/external): make `PKCE` on external auth optional (#3279) server/fhir/repo execute independent io concurrently (#3227) MeasureReportDisplay (#3242) Create documentation on creating test data using batches (#3247) Clarify project admin vs. Super admin (#3267) feat(fhircast): add `FHIRcast` OAuth 2.0 scopes (#3274) Adding Health Gorilla setup documentation and samples (#3250) fix-3238 gracefully shutdown server (#3239)
* Release Version 2.1.12 chore(actions): add console output for `prettier-fmt` Actions workflow (#3278) feat(auth/external): make `PKCE` on external auth optional (#3279) server/fhir/repo execute independent io concurrently (#3227) MeasureReportDisplay (#3242) Create documentation on creating test data using batches (#3247) Clarify project admin vs. Super admin (#3267) feat(fhircast): add `FHIRcast` OAuth 2.0 scopes (#3274) Adding Health Gorilla setup documentation and samples (#3250) fix-3238 gracefully shutdown server (#3239) * Fix package-lock.json
Fixes #3238