Monitor in docker (#109)

* Monitor in docker

* Update readme.

* Update crontab.example

* Removed examples from readme

* Update readme.
This commit is contained in:
Przemyslaw Rzad 2019-06-17 09:22:53 +02:00 committed by GitHub
parent 26ff22ac7e
commit 1da7340fb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 32 deletions

17
monitor/Dockerfile Normal file

@ -0,0 +1,17 @@
FROM node:8
WORKDIR /mono
COPY package.json .
COPY contracts/package.json ./contracts/
COPY monitor/package.json ./monitor/
COPY yarn.lock .
RUN yarn install --frozen-lockfile --production
COPY ./contracts ./contracts
RUN yarn run compile:contracts
RUN mv ./contracts/build ./ && rm -rf ./contracts/* ./contracts/.[!.]* && mv ./build ./contracts/
COPY ./monitor ./monitor
WORKDIR /mono/monitor
CMD echo "To start the monitor run:" \
"yarn start"

@ -110,43 +110,38 @@ cd monitor
cp .env.example .env
```
#### Example:
```bash
HOME_RPC_URL=https://sokol.poa.network
FOREIGN_RPC_URL=https://kovan.infura.io/mew
HOME_BRIDGE_ADDRESS=0xABb4C1399DcC28FBa3Beb76CAE2b50Be3e087353
FOREIGN_BRIDGE_ADDRESS=0xE405F6872cE38a7a4Ff63DcF946236D458c2ca3a
GAS_PRICE_SPEED_TYPE=standard
GAS_LIMIT=300000
GAS_PRICE_FALLBACK=21
LEFT_TX_THRESHOLD=100
```
## Check balances of contracts and validators
```
node checkWorker.js
```
## Check unprocessed events
```
node checkWorker2.js
```
## Run web interface
Using Yarn:
```
yarn start
```
To enabled debug logging, set `DEBUG=1` env variable.
You can run web interface via [pm2](https://www.npmjs.com/package/pm2) or similar supervisor program.
You can create cron job to run workers (see `crontab.example` for reference):
```bash
#crontab -e
*/4 * * * * cd $HOME/bridge-monitor; node checkWorker.js >>cronWorker.out 2>>cronWorker.err
*/5 * * * * cd $HOME/bridge-monitor; node checkWorker2.js >>cronWorker2.out 2>>cronWorker2.err
Using Docker:
```
docker-compose up -d
```
You can run web interface via [pm2](https://www.npmjs.com/package/pm2) or similar supervisor program.
- The application will run on `http://localhost:PORT`, where `PORT` is specified in your `.env` file.
- To enabled debug logging, set `DEBUG=1` variable in `.env`.
## Check balances of contracts and validators, get unprocessed events
Using Yarn:
```
yarn check-all
```
Using Docker:
```
docker-compose exec monitor yarn check-all
```
### Cron
You can create cron job to run workers (see `crontab.example` for reference):
## Linting
@ -156,7 +151,6 @@ Running linter:
yarn lint
```
## Contributing
See the [CONTRIBUTING](../CONTRIBUTING.md) document for contribution, testing and pull request protocol.

@ -1,2 +1,5 @@
*/4 * * * * cd $HOME/bridge-monitor; node checkWorker.js >>cronWorker.out 2>>cronWorker.err
*/5 * * * * cd $HOME/bridge-monitor; node checkWorker2.js >>cronWorker2.out 2>>cronWorker2.err
# Yarn:
*/4 * * * * cd $HOME/bridge-monitor; yarn check-all >>cronWorker.out 2>>cronWorker.err
# Docker:
*/4 * * * * cd $HOME/bridge-monitor; docker-compose exec monitor yarn check-all >>cronWorker.out 2>>cronWorker.err

@ -0,0 +1,13 @@
version: '2.4'
services:
monitor:
build:
context: ..
dockerfile: monitor/Dockerfile
ports:
- "${PORT}:${PORT}"
env_file: ./.env
environment:
- NODE_ENV=production
restart: unless-stopped
entrypoint: yarn start

@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"check-all": "node checkWorker.js && node checkWorker2.js",
"start": "node index.js",
"lint": "eslint . --ignore-path ../.eslintignore",
"lint:fix": "eslint . --fix"