Code Monkey home page Code Monkey logo

bdjuno-healthcheck-scheduler's Introduction

bdjuno-healthcheck-scheduler

image


Instruction

BDJuno allows users to use data according to their purpose by parsing data saved on the chain. Parsed data is saved on Postgresql(database) and through GraphQL users can inquire data to use them in a manner that suits their purpose. However, we've come across some problems on BDJuno and in order to solve this, this application monitors BDJuno.


Monitoring methods are as follows.

  • We inquire the height and check the change in height of the most recent block saved on the DB using GraphQL API.

If any error occurs, that error is reported to the Telegram of the dev team and immediately restarts the service using TELEGRAM COMMAND.


How to install & set config

1. Node Installation

Node version must be higher than 16.19.0

2. .env.production

The .env.production file configures your application's environment.


Prepare the file first.

cp .env.sample .env.production
vim .env.production

Configure the environment after checking the description of each environment variable.

PORT=4000
: Application Port

HASURA_ADMIN_SECRET=myhasuraKey%%
: Your_hasura_admin_secret_key

GRAPH_QL_URL=hasura_address:8080/v1/graphql
: url address of graph ql to request height

INTERVAL_SECONDS=300  (5 minutes)
: How often to check the height (seconds)

WARNING_STACK=5
: Warning Maximum Number

QUEUE_FILE_NAME=heightQueue.txt
: If there is no change in height, save it to the queue and send the stored height as an alert.

HEALTH_BOT_TOKEN=numbering:telegram_key_string
: Tokens in the health check bot

HEALTH_BOT_CHATID=chat_bot_numbering_id
: The ID of the Telegram chat room

NOTIFICATION_BOT_TOKEN=numbering:telegram_key_string
: Tokens in the notification bot

NOTIFICATION_BOT_CHATID=chat_bot_numbering_id
: The ID of the Telegram chat room

3. telegraf.constant.ts

Telegram bots help you control status check applications through simple commands.


Prepare the telegraf.constant.ts file.

cp telegraf.constant.sample.ts telegraf.constant.ts

Check the description of each command and configure the commands.

export const COMMAND_LIST = "/";
: Output GUIDE_DESC.

export const COMMAND_HEALTH_START = "";
: Initiates an interval to check the status. It also launches the BDJuno service.

export const COMMAND_HEALTH_STOP = "";
: Stops the interval during which the status check is performed. It also stops the BDJuno service.

export const COMMAND_HEALTH_RESTART = "";
: Restart the interval for which you want to check the status. It also restarts the BDJuno service.

export const COMMAND_HEALTH_JOB_NAME = "";
: Queries the name of the currently running interval. If it is not running, '[]' is output.

export const COMMAND_CLEAN_QUEUE = "";
: Clean up the contents of the queue file.

export const GUIDE_DESC = "";
: I recommend that you write down a description of the commands.

This is an example image of a Telegram command usage.

image


This is an example of a Telegram room that is being monitored.

image


4. Register BDJuno service

This application must be reprinted from the registration of BDJuno into the service. Use after modifying the location of User and BD Juno Deamon.

$ sudo tee /etc/systemd/system/bdjuno.service > /dev/null <<EOF
[Unit]
Description=BDJuno parser
After=network-online.target

[Service]
User="Your user name"
ExecReload=pkill '/usr/local/bin/bdjuno start' & /usr/local/bin/bdjuno start
ExecStart=/usr/local/bin/bdjuno start
RestartSec=3
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target
EOF

How to run

npm run start

REST API

API to check the status of the application.

# Path
/health

# How to request
curl -X GET http://localhost:4000/health

# Return
"OK"

bdjuno-healthcheck-scheduler's People

Contributors

thismars avatar

Stargazers

 avatar kimminki avatar  avatar  avatar  avatar InfinityStake avatar  avatar  avatar u2dao avatar LarryKim avatar  avatar  avatar  avatar  avatar Donghoon Kim avatar  avatar chill_beer avatar  avatar

Watchers

James Cloos avatar Donghoon Kim avatar  avatar kimminki avatar  avatar LarryKim avatar  avatar chill_beer avatar  avatar  avatar  avatar  avatar  avatar  avatar u2dao avatar  avatar  avatar InfinityStake avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.