feat: Add timeout to incoming requests
This commit is contained in:
@@ -167,6 +167,15 @@ export class Environment {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
public WEB_CONCURRENCY = this.toOptionalNumber(process.env.WEB_CONCURRENCY);
|
public WEB_CONCURRENCY = this.toOptionalNumber(process.env.WEB_CONCURRENCY);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How long a request should be processed before giving up and returning an
|
||||||
|
* error response to the client, defaults to 10s
|
||||||
|
*/
|
||||||
|
@IsNumber()
|
||||||
|
@IsOptional()
|
||||||
|
public REQUEST_TIMEOUT =
|
||||||
|
this.toOptionalNumber(process.env.REQUEST_TIMEOUT) ?? 10 * 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base64 encoded private key if Outline is to perform SSL termination.
|
* Base64 encoded private key if Outline is to perform SSL termination.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ async function start(id: number, disconnect: () => void) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.listen(normalizedPortFlag || env.PORT || "3000");
|
server.listen(normalizedPortFlag || env.PORT || "3000");
|
||||||
|
server.setTimeout(env.REQUEST_TIMEOUT);
|
||||||
|
|
||||||
process.once("SIGTERM", shutdown);
|
process.once("SIGTERM", shutdown);
|
||||||
process.once("SIGINT", shutdown);
|
process.once("SIGINT", shutdown);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user