Skip to content

Commit

Permalink
Use monitor docker hub image for monitor deployment (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar authored Feb 4, 2020
1 parent 52358d4 commit bce1e65
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 21 deletions.
2 changes: 1 addition & 1 deletion deployment/roles/monitor/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
dependencies:
- { role: common, check_deployed: true, component: 'monitor' }
- { role: common, skip_repo: true, check_deployed: true, component: 'monitor' }
4 changes: 2 additions & 2 deletions deployment/roles/monitor/tasks/jumpbox.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Build the containers
shell: docker-compose build
- name: Pull the containers images
shell: docker-compose pull
args:
chdir: "{{ bridge_path }}/monitor"
36 changes: 36 additions & 0 deletions deployment/roles/monitor/tasks/pre_config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
---
- name: Create configs directory
file:
path: "{{ bridge_path }}/monitor/configs"
state: directory
mode: '0755'
when: skip_task != true

- name: Create responses directory
file:
path: "{{ bridge_path }}/monitor/responses"
state: directory
mode: '0755'
when: skip_task != true

- name: Create scripts directory
file:
path: "{{ bridge_path }}/monitor/scripts"
state: directory
mode: '0755'
when: skip_task != true

- name: Install .env config
template:
src: .env.j2
dest: "{{ bridge_path }}/monitor/.env"
when: skip_task != true

- name: Copy docker-compose file
copy:
src: ../../../../monitor/docker-compose.yml
dest: "{{ bridge_path }}/monitor/docker-compose.yml"
mode: '0755'
when: skip_task != true

- name: Copy script file
copy:
src: ../../../../monitor/scripts/getBridgeStats.sh
dest: "{{ bridge_path }}/monitor/scripts/getBridgeStats.sh"
owner: "{{ compose_service_user }}"
mode: '0755'
when: skip_task != true

- name: Install bridge config env
template:
src: config.env.j2
Expand Down
1 change: 0 additions & 1 deletion deployment/roles/monitor/tasks/servinstall.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This role creates a tokenbridge-monitor service which is designed to manage docker-compose monitor deployment.
# /etc/init.d/tokenbridge-monitor start, status, stop, restart - does what the services usually do in such cases.
# /etc/init.d/tokenbridge-monitor rebuild - builds a new monitor deployment from scratch.
---
- name: "Set the service"
template:
Expand Down
14 changes: 1 addition & 13 deletions deployment/roles/monitor/templates/tokenbridge-monitor.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ status(){
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose ps
}

rebuild(){
echo "Rebuild TokenBridge Monitor.."
cd $WORKDIR
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose rm -fv
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose up --detach --force-recreate --no-deps --build
}


case "$1" in

Expand All @@ -63,12 +55,8 @@ case "$1" in
start
;;

rebuild)
rebuild
;;

*)
echo $"Usage: $0 {start|stop|restart|rebuild|status}"
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
;;

Expand Down
4 changes: 1 addition & 3 deletions monitor/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
version: '2.4'
services:
monitor:
build:
context: ..
dockerfile: monitor/Dockerfile
image: poanetwork/tokenbridge-monitor:latest
ports:
- "${MONITOR_PORT}:${MONITOR_PORT}"
env_file: ./.env
Expand Down
2 changes: 1 addition & 1 deletion monitor/scripts/getBridgeStats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd $(dirname $0)/..
if /usr/local/bin/docker-compose ps | grep -q -i 'monitor'; then
for file in configs/*.env
do
docker run --rm --env-file $file -v $(pwd)/responses:/mono/monitor/responses monitor_monitor /bin/bash -c 'yarn check-all'
docker run --rm --env-file $file -v $(pwd)/responses:/mono/monitor/responses poanetwork/tokenbridge-monitor:latest /bin/bash -c 'yarn check-all'
done
else
echo "Monitor is not running, skipping checks."
Expand Down

0 comments on commit bce1e65

Please sign in to comment.