From 1e6d70a5e0ab2e3fe24e82ad40b2b24a4ceca262 Mon Sep 17 00:00:00 2001 From: Stephen Fraser Date: Mon, 30 Oct 2023 15:34:48 +0000 Subject: [PATCH 1/3] Auto-restart --- ecosystem.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ecosystem.config.js b/ecosystem.config.js index 146cedf..5d9f689 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -30,6 +30,7 @@ module.exports = { // Options reference: https://pm2.keymetrics.io/docs/usage/application-declaration/ instances: 1, + cron_restart: '0 3 * * *', // 3AM each day. autorestart: true, watch: false, max_memory_restart: '1G', From 039534cf4be94a6d95f349227d463a5619f8569e Mon Sep 17 00:00:00 2001 From: Stephen Fraser Date: Mon, 30 Oct 2023 15:35:26 +0000 Subject: [PATCH 2/3] Auto-restart changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 936c688..937806a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security --> +## [v1.1.4](https://github.com/digirati-co-uk/tasks-api/compare/v1.1.3...v1.1.4) + +### Fixed +- Added restart schedule + ## [v1.1.3](https://github.com/digirati-co-uk/tasks-api/compare/v1.1.2...v1.1.3) ### Fixed From f5c9299bac32ec35ead29e8fd1628e703d46b1af Mon Sep 17 00:00:00 2001 From: Stephen Fraser Date: Mon, 30 Oct 2023 15:55:53 +0000 Subject: [PATCH 3/3] Configuration changes + postgres driver update --- package.json | 2 +- src/database/create-postgres-pool.ts | 5 +++- yarn.lock | 35 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e959a90..b5add9c 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "slonik-sql-tag-raw": "1.0.2" }, "dependencies": { - "pg": "^8.7.1", + "pg": "^8.11.3", "pm2": "^5.1.2", "bullmq": "^1.50.3" }, diff --git a/src/database/create-postgres-pool.ts b/src/database/create-postgres-pool.ts index 1da2484..fa4da5a 100644 --- a/src/database/create-postgres-pool.ts +++ b/src/database/create-postgres-pool.ts @@ -7,7 +7,10 @@ export function createPostgresPool(config: DBConfig) { ? config : `postgres://${config.username}:${config.password}@${config.host}:${config.port}/${config.database}`, { - connectionTimeout: 'DISABLE_TIMEOUT', + // connectionTimeout: 'DISABLE_TIMEOUT', + maximumPoolSize: 64, + connectionRetryLimit: 10, // DEFAULT: 3 + connectionTimeout: 30000, // 30 seconds - and then an error (*10 is 5 minutes) } ); } diff --git a/yarn.lock b/yarn.lock index 2050227..a76cf6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4483,6 +4483,11 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== +pg-cloudflare@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz#e6d5833015b170e23ae819e8c5d7eaedb472ca98" + integrity sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q== + pg-connection-string@^2.2.3, pg-connection-string@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.3.0.tgz#c13fcb84c298d0bfa9ba12b40dd6c23d946f55d6" @@ -4493,6 +4498,11 @@ pg-connection-string@^2.5.0: resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.5.0.tgz#538cadd0f7e603fc09a12590f3b8a452c2c0cf34" integrity sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ== +pg-connection-string@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.2.tgz#713d82053de4e2bd166fab70cd4f26ad36aab475" + integrity sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA== + pg-copy-streams-binary@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/pg-copy-streams-binary/-/pg-copy-streams-binary-1.3.0.tgz#ade7e2522d94c3ba017c4975bf8f4df546fde519" @@ -4559,6 +4569,11 @@ pg-pool@^3.4.1: resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.4.1.tgz#0e71ce2c67b442a5e862a9c182172c37eda71e9c" integrity sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ== +pg-pool@^3.6.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.6.1.tgz#5a902eda79a8d7e3c928b77abf776b3cb7d351f7" + integrity sha512-jizsIzhkIitxCGfPRzJn1ZdcosIt3pz9Sh3V01fm1vZnbnCMgmGl5wvGGdNN2EL9Rmb0EcFoCkixH4Pu+sP9Og== + pg-protocol@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.2.5.tgz#28a1492cde11646ff2d2d06bdee42a3ba05f126c" @@ -4569,6 +4584,11 @@ pg-protocol@^1.5.0: resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.5.0.tgz#b5dd452257314565e2d54ab3c132adc46565a6a0" integrity sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ== +pg-protocol@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.6.0.tgz#4c91613c0315349363af2084608db843502f8833" + integrity sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q== + pg-types@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-2.2.0.tgz#2d0250d636454f7cfa3b6ae0382fdfa8063254a3" @@ -4592,6 +4612,21 @@ pg-types@^3.0.0: postgres-date "~1.0.4" postgres-interval "^1.1.0" +pg@^8.11.3: + version "8.11.3" + resolved "https://registry.yarnpkg.com/pg/-/pg-8.11.3.tgz#d7db6e3fe268fcedd65b8e4599cda0b8b4bf76cb" + integrity sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g== + dependencies: + buffer-writer "2.0.0" + packet-reader "1.0.0" + pg-connection-string "^2.6.2" + pg-pool "^3.6.1" + pg-protocol "^1.6.0" + pg-types "^2.1.0" + pgpass "1.x" + optionalDependencies: + pg-cloudflare "^1.1.1" + pg@^8.2.1: version "8.3.0" resolved "https://registry.yarnpkg.com/pg/-/pg-8.3.0.tgz#941383300d38eef51ecb88a0188cec441ab64d81"