Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

Added health monitor #697

Merged
merged 31 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7c8fce0
Added health monitor
niklabh Apr 22, 2020
77acee6
Added health check for auth server
niklabh Apr 26, 2020
b8ff379
Added other statuses
niklabh Apr 26, 2020
10ace48
Merge branch 'master' into niklabh-feature-health-monitor
niklabh Apr 27, 2020
e5729a3
Added prisma version and rpc call
niklabh Apr 27, 2020
a52a2c2
Merge branch 'master' into niklabh-feature-health-monitor
niklabh Apr 30, 2020
caf9832
Added post with author query
niklabh Apr 30, 2020
1e066f9
Added HEALTH_PORT
niklabh Apr 30, 2020
4067f37
Update health-monitor/README.md
niklabh Apr 30, 2020
4836acc
license Apache-2.0
niklabh Apr 30, 2020
1dd18e4
lint
niklabh Apr 30, 2020
82539f3
accumulator
niklabh Apr 30, 2020
d543664
Getting latest block rather than finalised
niklabh Apr 30, 2020
fc2dfb9
added referendum delays
niklabh Apr 30, 2020
d490178
Merge branch 'master' into niklabh-feature-health-monitor
Tbaut May 4, 2020
d080fe9
Update chain-db-watcher/src/index.ts
niklabh May 4, 2020
3872df3
Update health-monitor/src/index.ts
niklabh May 4, 2020
097d26f
Update health-monitor/src/index.ts
niklabh May 4, 2020
eb0040c
Merge branch 'master' into niklabh-feature-health-monitor
Tbaut May 6, 2020
815ba22
Merge branch 'master' into niklabh-feature-health-monitor
niklabh May 11, 2020
94bd9db
using tsc
niklabh May 11, 2020
5ac72f3
fix
niklabh May 11, 2020
2b98e8c
moved to dev depen
niklabh May 11, 2020
13861a2
change as per review
niklabh May 11, 2020
5d3ce52
Merge branch 'master' into niklabh-feature-health-monitor
Tbaut May 11, 2020
bb2cc09
Fix health monitor
niklabh May 11, 2020
3f9ae78
Merge branch 'master' into niklabh-feature-health-monitor
Tbaut May 12, 2020
a43fba6
update @polkadt/api
Tbaut May 12, 2020
7d37ef7
post id can be null and onchain_referendum is an array
Tbaut May 12, 2020
9322c7b
fix threshold add logs and info
Tbaut May 12, 2020
306ab7c
Merge branch 'master' into niklabh-feature-health-monitor
niklabh May 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"Nikhil Rajan",
"Thibaut Sardan"
],
"license": "MIT",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/paritytech/polkassembly/issues"
},
Expand Down
1 change: 1 addition & 0 deletions chain-db-watcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COUNCIL_TOPIC_ID=2
TREASURY_TOPIC_ID=4
HASURA_GRAPHQL_ADMIN_SECRET=<your admin secret>
START_FROM=0
HEALTH_PORT=8019
```
## Run
- `yarn`
Expand Down
2 changes: 1 addition & 1 deletion chain-db-watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Nikhil Rajan",
"Thibaut Sardan"
],
"license": "MIT",
"license": "Apache-2.0",
niklabh marked this conversation as resolved.
Show resolved Hide resolved
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "yarn tsc && ts-node ./src/index.ts",
Expand Down
14 changes: 14 additions & 0 deletions chain-db-watcher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { execute } from 'apollo-link';
import { WebSocketLink } from 'apollo-link-ws';
import chalk from 'chalk';
import dotenv from 'dotenv';
import http from 'http';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import ws from 'ws';

Expand Down Expand Up @@ -208,6 +209,19 @@ async function main (): Promise<void> {
process.exit(1);
}
});

const hostname = '127.0.0.1';
const port = Number(process.env.HEALTH_PORT) || 8019;

const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('ok');
});

server.listen(port, hostname, () => {
console.log(`[+] Health endpoint available at http://${hostname}:${port}/`);
});
}

main().catch(error => console.error(chalk.red(error)));
2 changes: 1 addition & 1 deletion front-end/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "governance-platform",
"version": "0.1.0",
"license": "GPL-3.0",
"license": "Apache-2.0",
"private": true,
"homepage": "http://polkassembly.io/",
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions health-monitor/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
.env
11 changes: 11 additions & 0 deletions health-monitor/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# http://editorconfig.org/

root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = tab
indent_size = 4
1 change: 1 addition & 0 deletions health-monitor/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
49 changes: 49 additions & 0 deletions health-monitor/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/typescript",
"semistandard"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json"]
},
"plugins": [
"@typescript-eslint",
"header",
"security",
"promise",
"simple-import-sort"
],
"rules": {
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-unused-vars": "error",
"arrow-spacing":["warn",{ "before": true, "after": true }],
"camelcase": "off",
"comma-dangle": ["error", "never"],
"header/header": [2, "../header.js"],
"indent": ["error", "tab"],
"no-extra-parens": ["error", "all", { "returnAssign": false }],
"no-multiple-empty-lines": ["error", {"max": 1}],
"no-tabs": ["error", { "allowIndentationTabs": true }],
"no-trailing-spaces": ["warn"],
"no-unused-vars": "off",
"object-curly-spacing": ["error", "always"],
"quotes": ["error", "single", { "avoidEscape": true }],
"semi": [2, "always"],
"simple-import-sort/sort": "error",
"sort-keys": ["error", "asc", {"caseSensitive": true, "natural": false, "minKeys": 2}],
"switch-colon-spacing": ["error", {"after": true, "before": false}]
}
}
7 changes: 7 additions & 0 deletions health-monitor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.env
data
build
*.sh
*.log
docker-compose.yaml
18 changes: 18 additions & 0 deletions health-monitor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:12

RUN mkdir -p /opt/app

RUN chown node:node /opt/app

WORKDIR /opt/app

COPY --chown=node:node package.json .
COPY --chown=node:node yarn.lock .

USER node

RUN yarn

COPY --chown=node:node . .

CMD yarn start:prod
19 changes: 19 additions & 0 deletions health-monitor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## health-monitor

Health monitor service for Polkassembly. Provides a single API endpoint which checks the health of all Polkassembly components.

## Installation

Configure environment variables with a .env file with following values.

```bash
PORT=8034
AUTH_SERVER="http://localhost:8010"
HASURA_SERVER="http://localhost:8080"
CHAIN_DB_WATCHER_SERVER="http://localhost:8019"
CHAIN_DB_SERVER="http://0.0.0.0:4000"
CHAIN_DB="http://0.0.0.0:4466"
REACT_SERVER="http://localhost:3000"
ARCHIVE_NODE_ENDPOINT="wss://kusama-rpc.polkadot.io"
```

40 changes: 40 additions & 0 deletions health-monitor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "health-monitor",
"version": "0.0.1",
"description": "Healthcheck Monitoring for polkassembly",
"main": "index.js",
"scripts": {
"start": "ts-node src/index.ts",
niklabh marked this conversation as resolved.
Show resolved Hide resolved
"tsc": "tsc",
"start:prod": "tsc && node build/index.js",
"lint": "npx eslint ./src/ --ext .js,.ts",
"lint:fix": "npx eslint ./src/ --ext .js,.ts --fix"
},
"dependencies": {
"@polkadot/api": "^1.13.1",
"dotenv": "^8.2.0",
"express": "^4.16.4",
"node-fetch": "^2.6.0",
"typescript": "^3.8.3"
},
"devDependencies": {
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.2",
"@types/node": "^12.12.11",
"@types/node-fetch": "^2.5.5",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"eslint": "^6.8.0",
"eslint-config-semistandard": "^15.0.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-simple-import-sort": "^5.0.2",
"eslint-plugin-standard": "^4.0.1",
"ts-node": "^8.5.4"
},
"license": "Apache-2.0"
}
Loading