Skip to content

Commit a5f10ac

Browse files
authored
1 parent 9b41061 commit a5f10ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+12732
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
git_branch=$(git symbolic-ref --short -q HEAD)
3+
4+
# delete existing service
5+
docker service rm rpc_monitor
6+
7+
# create new service
8+
docker service create \
9+
--name rpc_monitor \
10+
--replicas 1 \
11+
--network cosmosia \
12+
--restart-condition none \
13+
archlinux:latest \
14+
/bin/bash -c \
15+
"curl -s https://raw.githubusercontent.com/baabeetaa/cosmosia/$git_branch/rpc_monitor/run.sh > ~/run.sh && /bin/bash ~/run.sh"
16+
17+

rpc_monitor/get_status.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
RPC_SERVICES="osmosis starname regen akash cosmoshub sentinel emoney ixo juno sifchain likecoin kichain cyber cheqd stargaze bandchain chihuahua kava bitcanna konstellation omniflixhub terra vidulum provenance dig gravitybridge"
3+
#TMP_DIR="$HOME/tmp"
4+
TMP_DIR="./web/build"
5+
TMP_STATUS_FILE="$TMP_DIR/status.json"
6+
#mkdir -p $TMP_DIR
7+
8+
service_str=""
9+
for service_name in $RPC_SERVICES; do
10+
ips=$(dig +short "tasks.$service_name" |sort)
11+
12+
tmp_str=""
13+
while read -r ip_addr || [[ -n $ip_addr ]]; do
14+
status_code=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 --max-time 3 "http://$ip_addr/healthcheck")
15+
16+
if [[ ! -z "$tmp_str" ]]; then
17+
tmp_str="$tmp_str,"$'\n'
18+
fi
19+
tmp_str="$tmp_str"" { \"ip\": \"$ip_addr\", \"status\": $status_code }"
20+
21+
done < <(echo "$ips")
22+
23+
if [[ ! -z "$service_str" ]]; then
24+
service_str="$service_str,"$'\n'
25+
fi
26+
service_str="$service_str { \"service\": \"$service_name\", \"containers\": [ $tmp_str ] }"
27+
done
28+
29+
echo "[ $service_str ]" > $TMP_STATUS_FILE

rpc_monitor/run.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
pacman -Syu --noconfirm
2+
pacman -S --noconfirm base-devel dnsutils git nodejs npm yarn python2 screen
3+
4+
cd $HOME
5+
6+
git clone --single-branch --branch rpc_monitor https://github.com/baabeetaa/cosmosia
7+
8+
cd $HOME/cosmosia/rpc_monitor/web
9+
10+
11+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
12+
export NVM_DIR="$HOME/.nvm"
13+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
14+
15+
nvm install v10.24.1
16+
17+
yarn && yarn build
18+
19+
screen -S caddy -dm node server.js
20+
21+
22+
#########
23+
cd $HOME/cosmosia/rpc_monitor
24+
25+
while true; do
26+
/bin/bash get_status.sh
27+
28+
# sleep 120 seconds...
29+
sleep 120
30+
done

rpc_monitor/web/.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# rules for all the files
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 2
12+
13+
[/src/client/locales/**]
14+
insert_final_newline = false

rpc_monitor/web/.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Ignore Mac DS_Store files
2+
.DS_Store
3+
**/.DS_Store
4+
5+
# project file
6+
.idea
7+
*.iml
8+
9+
# dependencies
10+
/node_modules
11+
12+
13+
/dist
14+
/build
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*
18+
19+
.npmrc

rpc_monitor/web/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Epexa
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

rpc_monitor/web/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Getting Started
2+
3+
```
4+
yarn
5+
yarn start
6+
```
7+
8+
Open `http://localhost:3000/`

rpc_monitor/web/package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "monitor",
3+
"version": "0.1.0",
4+
"description": "cosmosia rpc monitor",
5+
"main": "index.js",
6+
"repository": "[email protected]/baabeetaa/cosmosia.git",
7+
"author": "Tuan Pham Anh <[email protected]>",
8+
"license": "MIT",
9+
"private": false,
10+
"scripts": {
11+
"start": "react-scripts start",
12+
"build": "GENERATE_SOURCEMAP=false react-scripts build",
13+
"watch": "cra-build-watch",
14+
"test": "react-scripts test",
15+
"eject": "react-scripts eject"
16+
},
17+
"dependencies": {
18+
"antd": "^3.19.3",
19+
"assert": "^2.0.0",
20+
"connected-react-router": "^6.4.0",
21+
"dotenv": "4.0.0",
22+
"history": "^4.9.0",
23+
"hoist-non-react-statics": "^3.3.0",
24+
"immer": "^4.0.0",
25+
"intl": "^1.2.5",
26+
"invariant": "^2.2.4",
27+
"lodash": "^4.17.15",
28+
"node-fetch": "^1.7.3",
29+
"node-sass": "^4.12.0",
30+
"prop-types": "^15.7.2",
31+
"react": "^16.8.6",
32+
"react-dom": "^16.8.6",
33+
"react-json-view": "^1.19.1",
34+
"react-redux": "7.0.2",
35+
"react-router-dom": "5.0.0",
36+
"react-scripts": "3.0.1",
37+
"redux": "4.0.1",
38+
"redux-saga": "^1.0.3",
39+
"reselect": "^4.0.0",
40+
"sass-loader": "^8.0.0"
41+
},
42+
"eslintConfig": {
43+
"extends": "react-app"
44+
},
45+
"browserslist": [],
46+
"devDependencies": {
47+
}
48+
}
3.78 KB
Binary file not shown.

rpc_monitor/web/public/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" type="image/png" href="/assets/img/favicon.ico">
6+
<link rel="apple-touch-icon" sizes="76x76" href="/assets/img/apple-icon.png">
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
8+
9+
<title>Monitor</title>
10+
11+
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
12+
<meta name="viewport" content="width=device-width" />
13+
14+
</head>
15+
<body>
16+
<div id="root"></div>
17+
18+
</body>
19+
20+
</html>

0 commit comments

Comments
 (0)