Add cron schedule to monitor deployment playbook (#161)

* Default cron schedule

* Added cron task

* Docs

* Overwriting log files

* Removed deprecated flag

* Default monitor_cron_schedule.
This commit is contained in:
Przemyslaw Rzad 2019-07-26 15:59:30 +02:00 committed by GitHub
parent c66923827b
commit 9c8259700b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 32 additions and 4 deletions

@ -47,6 +47,7 @@ cp hosts.yml.example hosts.yml
<host_ip_B>:
ansible_user: <user>
#syslog_server_port: "<protocol>://<ip>:<port>"
#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>`.

@ -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: "* * * * *"

@ -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: "* * * * *"

@ -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: "* * * * *"

@ -17,3 +17,4 @@ sokol-kovan:
127.0.0.1:
ansible_user: ubuntu
#syslog_server_port: "<protocol>://<ip>:<port>"
#monitor_cron_schedule: "*/4 * * * *"

@ -0,0 +1,2 @@
---
monitor_cron_schedule: "*/4 * * * *"

@ -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 }}"

@ -3,3 +3,4 @@
- include_tasks: logging.yml
- include_tasks: jumpbox.yml
- include_tasks: servinstall.yml
- include_tasks: cron.yml

@ -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
monitor/scripts/checkDocker.sh Executable file

@ -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