Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cron schedule to monitor deployment playbook #161

Merged
merged 11 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
1 change: 1 addition & 0 deletions deployment/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ cp hosts.yml.example hosts.yml
hosts:
<host_ip_B>:
ansible_user: <user>
#monitor_cron_schedule: "*/4 * * * *" # When this parameter is set, it will overwrite default schedule for performing checks
```

The config above would install the Oracle on `<host_ip_A>`, UI on `<host_ip_C>`, and both Oracle, UI and Monitor on `<host_ip_B>`.
Expand Down
1 change: 0 additions & 1 deletion deployment/group_vars/dai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ MONITOR_FOREIGN_GAS_LIMIT: 300000
MONITOR_HOME_GAS_PRICE_FALLBACK: 0
MONITOR_FOREIGN_GAS_PRICE_FALLBACK: 10000000000
MONITOR_LEFT_TX_THRESHOLD: 100
MONITOR_CRON_SCHEDULE: "* * * * *"
1 change: 0 additions & 1 deletion deployment/group_vars/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ MONITOR_FOREIGN_GAS_LIMIT: 300000
MONITOR_HOME_GAS_PRICE_FALLBACK: 1000000000
MONITOR_FOREIGN_GAS_PRICE_FALLBACK: 1000000000
MONITOR_LEFT_TX_THRESHOLD: 100
MONITOR_CRON_SCHEDULE: "* * * * *"
1 change: 0 additions & 1 deletion deployment/group_vars/wetc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ MONITOR_FOREIGN_GAS_LIMIT: 300000
MONITOR_HOME_GAS_PRICE_FALLBACK: 15000000000
MONITOR_FOREIGN_GAS_PRICE_FALLBACK: 10000000000
MONITOR_LEFT_TX_THRESHOLD: 100
MONITOR_CRON_SCHEDULE: "* * * * *"
1 change: 1 addition & 0 deletions deployment/hosts.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ sokol-kovan:
hosts:
127.0.0.1:
ansible_user: ubuntu
#monitor_cron_schedule: "*/4 * * * *"
1 change: 0 additions & 1 deletion deployment/roles/common/files/daemon.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"disable-legacy-registry": true,
"live-restore": true,
"no-new-privileges": true
}
2 changes: 2 additions & 0 deletions deployment/roles/monitor/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
monitor_cron_schedule: "*/4 * * * *"
18 changes: 18 additions & 0 deletions deployment/roles/monitor/tasks/cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Parse cron schedule
set_fact:
minute: "{{ monitor_cron_schedule.split(' ')[0] }}"
hour: "{{ monitor_cron_schedule.split(' ')[1] }}"
day: "{{ monitor_cron_schedule.split(' ')[2] }}"
month: "{{ monitor_cron_schedule.split(' ')[3] }}"
weekday: "{{ monitor_cron_schedule.split(' ')[4] }}"
job: "/bin/bash -c 'cd {{ bridge_path }}/monitor/scripts; ./checkDocker.sh >cronWorker.out 2>cronWorker.err'"
- name: Add cron entry
cron:
name: "RUN_MONITOR_CHECKS"
minute: "{{ minute }}"
hour: "{{ hour }}"
day: "{{ day }}"
month: "{{ month }}"
weekday: "{{ weekday }}"
job: "{{ job }}"
1 change: 1 addition & 0 deletions deployment/roles/monitor/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
- include_tasks: pre_config.yml
- include_tasks: jumpbox.yml
- include_tasks: servinstall.yml
- include_tasks: cron.yml
1 change: 0 additions & 1 deletion deployment/roles/monitor/templates/.env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ FOREIGN_GAS_PRICE_FALLBACK={{ MONITOR_FOREIGN_GAS_PRICE_FALLBACK }}
FOREIGN_GAS_PRICE_FACTOR={{ FOREIGN_GAS_PRICE_FACTOR }}
LEFT_TX_THRESHOLD={{ MONITOR_LEFT_TX_THRESHOLD }}
PORT={{ MONITOR_PORT }}
CRON_SCHEDULE={{ MONITOR_CRON_SCHEDULE }}
9 changes: 9 additions & 0 deletions monitor/scripts/checkDocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
cd $(dirname $0)/..

if /usr/local/bin/docker-compose ps | grep -q -i 'monitor'; then
# https://github.com/docker/compose/issues/3352
COMPOSE_INTERACTIVE_NO_CLI=1 /usr/local/bin/docker-compose exec -T monitor /bin/bash -c 'yarn check-all'
else
echo "Monitor is not running, skipping checks."
fi