Skip to content

Commit

Permalink
improve healthcheck (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellenn-A authored Nov 25, 2024
1 parent 6faa1e2 commit 7513a3b
Show file tree
Hide file tree
Showing 11 changed files with 352 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Use a `.env` at root of the repository to set values for the environment variabl
| IPFS_PORT | N | `5001` | Port of the `IPFS` node to use for metadata storage |
| WATCHER_POLL_PERIOD_MS | N | `10000` | Number of ms between polling of service state |
| WATCHER_TIMEOUT_MS | N | `2000` | Timeout period in ms for service state |
| INDEXER_TIMEOUT_MS | N | `30000` | Timeout period in ms for service state |
| API_SWAGGER_BG_COLOR | N | `#fafafa` | CSS \_color\* val for UI bg ( try: [e4f2f3](https://coolors.co/e4f2f3) , [e7f6e6](https://coolors.co/e7f6e6) or [f8dddd](https://coolors.co/f8dddd) ) |
| API_SWAGGER_TITLE | N | `IdentityAPI` | String used to customise the title of the html page |
| API_SWAGGER_HEADING | N | `IdentityService` | String used to customise the H2 heading |
Expand Down
72 changes: 72 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"db:migrate": "npm run db:cmd -- migrate:latest --knexfile src/lib/db/knexfile.ts",
"db:rollback": "npm run db:cmd -- migrate:rollback --knexfile src/lib/db/knexfile.ts",
"coverage": "c8 npm run test",
"flows": "npx @digicatapult/sqnc-process-management@latest create -h localhost -p 9944 -u //Alice -f processFlows.json"
"flows": "process-management create -h localhost -p 9944 -u //Alice -f processFlows.json"
},
"repository": {
"type": "git",
Expand All @@ -38,6 +38,7 @@
},
"homepage": "https://github.com/digicatapult/sqnc-matchmaker-api#readme",
"devDependencies": {
"@digicatapult/sqnc-process-management": "^2.2.131",
"@digicatapult/tsimp": "^2.0.12",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.15.0",
Expand Down
1 change: 1 addition & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const env = envalid.cleanEnv(process.env, {
IPFS_PORT: envalid.port({ default: 5001 }),
WATCHER_POLL_PERIOD_MS: envalid.num({ default: 10 * 1000 }),
WATCHER_TIMEOUT_MS: envalid.num({ default: 2 * 1000 }),
INDEXER_TIMEOUT_MS: envalid.num({ default: 30 * 1000 }),
API_SWAGGER_BG_COLOR: envalid.str({ default: '#fafafa' }),
API_SWAGGER_TITLE: envalid.str({ default: 'MatchmakerAPI' }),
API_SWAGGER_HEADING: envalid.str({ default: 'MatchmakerAPI' }),
Expand Down
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'reflect-metadata'

import { Express } from 'express'
import { container } from 'tsyringe'

Expand All @@ -14,8 +13,18 @@ import { logger } from './lib/logger.js'

if (env.ENABLE_INDEXER) {
const node = container.resolve(ChainNode)
container.register<Indexer>('Indexer', {
useFactory: () =>
new Indexer({
db: new Database(),
logger,
node,
startupTime: new Date(),
env: env,
}),
})
const indexer = container.resolve<Indexer>('Indexer')

const indexer = new Indexer({ db: new Database(), logger, node })
await indexer.start()
indexer.processAllBlocks(await node.getLastFinalisedBlockHash()).then(() =>
node.watchFinalisedBlocks(async (hash) => {
Expand Down
Loading

0 comments on commit 7513a3b

Please sign in to comment.