Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit a3f4bb7

Browse files
committed
edits to docker-parity and stack (documentation, code reorg)
1 parent 007cde3 commit a3f4bb7

File tree

13 files changed

+75
-47
lines changed

13 files changed

+75
-47
lines changed

Diff for: stack/Dockerfile-parity

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ COPY ./parity/chain/spec.json spec.json
1111
COPY ./parity/chain/reserved_peers reserved_peers
1212

1313
ARG PARITY_ID
14-
ARG AWS_ACCESS_KEY_ID
15-
ARG AWS_SECRET_ACCESS_KEY
16-
ARG RESTORE_FILE
14+
ARG S3_ACCESS_KEY_ID
15+
ARG S3_SECRET_ACCESS_KEY
16+
ARG S3_BUCKET_NAME
1717

1818
RUN echo "Building parity${PARITY_ID}..."
1919

@@ -23,7 +23,7 @@ COPY ./parity/${PARITY_ID}/parity ./data/keys/parity
2323
COPY ./parity/${PARITY_ID}/network.key ./data/network/key
2424

2525
RUN mkdir ~/.aws
26-
RUN echo "[default]\naws_access_key_id = $AWS_ACCESS_KEY_ID\naws_secret_access_key = $AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials
26+
RUN echo "[default]\naws_access_key_id = $S3_ACCESS_KEY_ID\naws_secret_access_key = $S3_SECRET_ACCESS_KEY" > ~/.aws/credentials
2727

2828
RUN apt-get update -y
2929
RUN apt-get install -y curl bash redis-tools
@@ -32,10 +32,7 @@ RUN apt-get install nodejs -y && \
3232
rm -rf /tmp/*
3333

3434
COPY ./package* /parity/
35-
COPY ./docker/entrypoint-parity.sh entrypoint-parity.sh
36-
COPY ./docker/cron-job.js /parity/
37-
COPY ./docker/cron-job.sh /parity/
38-
COPY ./docker/download.js /parity/
35+
COPY ./backup /parity/
3936
RUN npm install
4037

4138
ENTRYPOINT [ "bash", "./entrypoint-parity.sh" ]

Diff for: stack/docker/download.js renamed to stack/backup/download.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const downloadFile = async () => {
1111

1212
const params = {
1313
Bucket: 'ab-parity-backups',
14-
Key: `base-app-mantle/parity${parityID}/${fileName}`
14+
Key: `launchpad-dev/parity${parityID}/${fileName}`
1515
}
1616
const backupStream = s3.getObject(params).createReadStream()
1717
const writeStream = fs.createWriteStream(fileName);

Diff for: stack/docker/entrypoint-parity.sh renamed to stack/backup/entrypoint-parity.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ for i in 1 2 3; do
2323
done
2424

2525
# NOTE: uncomment to activate backups
26-
# node /parity/cron-job.js
26+
# node /parity/parity-backup-cron-setup.js
2727

2828
/parity/parity --chain /parity/spec.json --config /parity/authority.toml -d /parity/data

Diff for: stack/docker/cron-job.js renamed to stack/backup/parity-backup-cron-setup.js

+29-20
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,41 @@ const fs = require('fs')
33
const AWS = require('aws-sdk')
44
const { exec } = require('child_process')
55

6+
const BUCKET_NAME = 'ab-parity-backups'
7+
68
const s3 = new AWS.S3()
79

8-
// Run task every day at 06:00 (using container timezone)
9-
cron.schedule('* 06 * * *', () => {
10-
console.log('RUNNING PARITY BACKUP TASK...')
10+
const createFilename = () => {
11+
const date = new Date()
12+
13+
let day = date.getDate()
14+
day = day < 10 ? `0${day}` : `${day}`
15+
16+
let month = date.getMonth() + 1
17+
month = month < 10 ? `0${month}` : `${month}`
18+
19+
const year = `${date.getFullYear()}`
20+
21+
return `${year}-${month}-${day}.tar.gz`
22+
}
23+
24+
const runBackup = () => {
25+
console.log('Running Parity backup task...')
1126

1227
const parityID = process.env.PARITY_ID
1328
const backupName = createFilename()
14-
const command = `sh cron-job.sh ${backupName}`
29+
const command = `sh parity-backup-tar.sh ${backupName}`
1530

1631
const execution = exec(command)
1732
execution.stdout.on('data', (data) => {
1833
// Archiving has been completed - we can now upload to S3
1934
if (data.trim() === 'Archive complete...') {
2035
const body = fs.readFileSync(`./${backupName}`)
2136
const params = {
22-
Bucket: 'ab-parity-backups',
37+
Bucket: BUCKET_NAME,
2338
Body: body,
24-
Key: `base-app-mantle/parity${parityID}/${backupName}`
39+
Key: `launchpad-dev/parity${parityID}/${backupName}`
2540
}
26-
2741
s3.upload(params, (err, data) => {
2842
if (err) {
2943
console.log(`S3 upload error: ${err}`)
@@ -33,18 +47,13 @@ cron.schedule('* 06 * * *', () => {
3347
})
3448
}
3549
})
36-
})
37-
38-
function createFilename() {
39-
const date = new Date()
40-
41-
let day = date.getDate()
42-
day = day < 10 ? `0${day}` : `${day}`
50+
}
4351

44-
let month = date.getMonth() + 1
45-
month = month < 10 ? `0${month}` : `${month}`
46-
47-
const year = `${date.getFullYear()}`
52+
const setupCron = () => {
53+
// Run task every day at 06:00 (using container timezone)
54+
cron.schedule('* 06 * * *', () => {
55+
runBackup()
56+
})
57+
}
4858

49-
return `${year}-${month}-${day}.tar.gz`
50-
}
59+
setupCron()
File renamed without changes.

Diff for: stack/docs/Pingdom.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Pingdom
2+
3+
This guide has the key points you neeed to set up Pingom
4+
5+
### Setting up on Slack
6+
7+
Visit [Slack's app manager](https://appliedblockchain.slack.com/apps/manage) for Applied Blockchain.
8+
9+
* Search for **Pingdom** on the list of apps then click on it.
10+
* Click on **Add Configuration**.
11+
* Choose the channel to be notified (use either the project's channel or *projectname-notifications*).
12+
* Click on **Add Pingdom Integration**.
13+
14+
You'll be redirected to a page with more configuration's to add onto Pingdom but for now, all we'll need is the **Webhook URL**.
15+
16+
### Setting up on Pingdom
17+
18+
Visit [Pingdom's Official Website](https://www.pingdom.com/) and login. We should have a shared account on [1Password](https://1password.com/).
19+
There are a couple of checks you should do before actually integrating the monitoring:
20+
21+
- Go to the **Users and teams** tab then **Users**. If you've not been added already, please do it yourself.
22+
- Go to the **Users and teams** tab then **Teams**. If your team/project is not added already, please do and add all the appropriate members.
23+
24+
#### Integrating Pingdom
25+
26+
* Go to **Integration** and click on **Integrations** tab.
27+
* Click on **Add new**. Put an appropriate name to the webhook as well as the **Webhook URL** we've just got from Slack. Click **Save Integration**.
28+
* Go to **Experience Monitoring** and click on the **Uptime** tab.
29+
* Click on **Add new**. A window will popup and you should set the appropriate fields for the API healthcheck route:
30+
* Name: should be compatible to the project API to be monitored;
31+
* Web: HTTP(s);
32+
* URL/IP: *https://* *example.io/api/health*;
33+
* Optional tab: insert port if needed
34+
* Who to alert: check your team or individuals;
35+
* Scroll down the window and check *your webhook* you've inserted on the integration's tab.
36+
* **Add** the new check you've configured.
37+
38+
You can then try to test the monitoring service by clicking on **Test** within the Uptime window.

Diff for: stack/explorer/.keep

Whitespace-only changes.

Diff for: stack/logging/elasticsearch/.keep

Whitespace-only changes.

Diff for: stack/logging/kibana/.keep

Whitespace-only changes.

Diff for: stack/logging/logstash/.keep

Whitespace-only changes.

Diff for: stack/monitor/app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@
6161
"WS_SECRET" : "OurDashSecret93%",
6262
"VERBOSITY" : 3
6363
}
64-
}
64+
}
6565

6666
]

Diff for: stack/monitoring/.keep

Whitespace-only changes.

Diff for: stack/README.md renamed to stack/prometheus/README.md

-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Stack
2-
3-
Stack information for deployment with parity nodes, prometheus, grafana and others.
4-
51
## Prometheus
62

73
Metrics source
@@ -33,7 +29,6 @@ ExecStart=/usr/bin/dockerd -H fd:// \
3329
docker-compose -f docker-compose.yml -f add-prometheus.yml up
3430
```
3531

36-
3732
## Possible Usage
3833
* Multiple datasource from different metrics datasources (e.g. Postgres, Azure, AWS)
3934
* Use of Prometheus Alert to sent alerts
@@ -44,14 +39,3 @@ docker-compose -f docker-compose.yml -f add-prometheus.yml up
4439
## Known Issues
4540
* Settting prometheus datasource to be browser
4641
Prometheus datasource is not accessible via grafana and should be changed to `Browser` instead of `Server`
47-
48-
# Docker Dev
49-
## How to Use
50-
51-
1. Install docker and docker compose
52-
2. In a terminal, run `source docker-aliases.sh`
53-
3. You might need to run `npm i && npm run compile` in the contracts folder if you haven't already.
54-
4. Start parity only: `mantle-compose up parity`
55-
5. While parity is running, deploy the contracts(run `npm run deploy` from the contracts folder).
56-
6. Run `mantle-compose build` to build the api and react images
57-
7. Stop parity and run `mantle-compose up` to start all the services

0 commit comments

Comments
 (0)