Skip to content

Commit

Permalink
Adding runtimeRestarter
Browse files Browse the repository at this point in the history
Fixes #223

+ Adding prom-client dependency, because it was removed from
@eng-automation/js (rightfully so)
  • Loading branch information
mutantcornholio committed Mar 5, 2024
1 parent 5da338c commit b131f0d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"pre-commit": "yarn lint-staged"
},
"dependencies": {
"@eng-automation/js": "^1.0.0",
"@eng-automation/js": "^1.0.3",
"@polkadot/api": "^10.10.1",
"@polkadot/keyring": "^12.5.1",
"@polkadot/util": "^12.5.1",
Expand All @@ -65,6 +65,7 @@
"express": "4.17.3",
"matrix-js-sdk": "^26.1.0",
"pg": "^8.11.2",
"prom-client": "^14.2.0",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",
"typeorm": "^0.3.17"
Expand Down
17 changes: 17 additions & 0 deletions src/start.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import "reflect-metadata";

import { runtimeRestarter } from "@eng-automation/js";

import { startBot } from "./bot";
import { AppDataSource } from "./db/dataSource";
import polkadotActions from "./dripper/polkadot/PolkadotActions";
import polkadotApi from "./dripper/polkadot/polkadotApi";
import { logger } from "src/logger";
import { startServer } from "./server";

(async () => {
Expand All @@ -11,6 +15,19 @@ import { startServer } from "./server";
// Thus, listening to port on the server side can be treated as "ready" signal.
await startBot();
await polkadotActions.isReady;
void runtimeRestarter({
metadata: {
getMetadataVersion: async () => {
return (await polkadotApi.rpc.state.getMetadata()).version.toString();
},
onMetadataChange: () => process.exit(0),
},
runtime: {
getRuntimeVersionHash: async () => (await polkadotApi.rpc.state.getRuntimeVersion()).hash.toString(),
onRuntimeChange: () => process.exit(0),
},
log: logger.info,
});
startServer();
})().catch((e) => {
console.error("Start failed:", e);
Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,10 @@
prettier-plugin-svelte "^3.0.3"
svelte "^3.54.0"

"@eng-automation/js@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@eng-automation/js/-/js-1.0.0.tgz#f6bd5e36f1ab047cdf185be913283788432003b0"
integrity sha512-LHRJYdug9zhCHGUBJc4KdPIlAKLFMC4sTgIT2fqrM2+v61e/y51fijrxRQ86gzcNG+ODrYJf0+9pCH5bNbaFTA==
"@eng-automation/js@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@eng-automation/js/-/js-1.0.3.tgz#57344622d389157734866ca21a6fabd7f33db665"
integrity sha512-AQITUg8uuZ2boB7I4yvjj5jluspNGI81xYl7GlYLBlaHRsehpffopZDA3W/4Bg2JDxQzczd1np20xOFkFo90xA==
dependencies:
async-mutex "^0.3.2"
commander "^9.3.0"
Expand All @@ -583,7 +583,6 @@
joi-to-typescript "^4.0.5"
lodash "^4.17.21"
node-fetch "^2.6.7"
prom-client "^14.2.0"

"@eslint-community/eslint-utils@^4.2.0":
version "4.4.0"
Expand Down

0 comments on commit b131f0d

Please sign in to comment.