Skip to content

Commit

Permalink
Added server timeouts to cleanup connections
Browse files Browse the repository at this point in the history
talkol committed Dec 27, 2020
1 parent da60e90 commit 9f79dd9
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
"@types/lodash": "^4.14.149",
"@types/luxon": "^1.22.0",
"@types/mock-fs": "^4.10.0",
"@types/node": "^12.12.32",
"@types/node": "^14.14.16",
"@types/node-fetch": "^2.5.5",
"@types/yargs": "^15.0.4",
"@typescript-eslint/eslint-plugin": "^2.25.0",
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@ import { renderServiceStatus } from './api/render-status';
import * as Logger from './logger';
import { StatusWriter } from './status-writer';

const SOCKET_TIMEOUT_SEC = 60;

// function wrapAsync(fn: RequestHandler): RequestHandler {
// return (req, res, next) => fn(req, res, next).catch(next);
// }
@@ -76,6 +78,8 @@ export function serve(serviceConfig: ServiceConfiguration) {
const server = app.listen(serviceConfig.Port, '0.0.0.0', () =>
Logger.log(`Management service listening on port ${serviceConfig.Port}!`)
);
server.setTimeout(SOCKET_TIMEOUT_SEC * 1000);
server.requestTimeout = SOCKET_TIMEOUT_SEC * 1000;
server.on('close', () => {
blockSyncTask.stop();
imagePollTask.stop();

0 comments on commit 9f79dd9

Please sign in to comment.