Skip to content

Commit

Permalink
Merge pull request #16 from ehh-why-its-so-hard/health-check
Browse files Browse the repository at this point in the history
feat: add health-check to all nodes
  • Loading branch information
daniel1302 authored Oct 26, 2024
2 parents ebb3e4c + 548ec61 commit bd5df72
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
4 changes: 4 additions & 0 deletions roles/vega_core/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ vega_core_block_explorer_postgresql_database: "tendermint"
vega_core_block_explorer_postgresql_password: "tendermint"

vega_core_data_node_settings: {}

vega_core_with_health_check: true
vega_core_health_check_repository: "nebula-dex/vega-health-check"
vega_core_health_check_version: "v0.1.0"
9 changes: 8 additions & 1 deletion roles/vega_core/handlers/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
ansible.builtin.service:
state: "{{- 'restarted' if vega_core_run_network else 'stopped' -}}"
daemon_reload: true

name: vegavisor
listen: "Restart vegavisor"
when: not ansible_check_mode
Expand All @@ -15,3 +14,11 @@
name: blockexplorer
listen: "Restart blockexplorer"
when: not ansible_check_mode

- name: Restart vega-health-check
ansible.builtin.service:
state: "{{- 'restarted' if vega_core_run_network else 'stopped' -}}"
daemon_reload: true
name: vega-health-check
listen: "Restart vega-health-check"
when: not ansible_check_mode
16 changes: 16 additions & 0 deletions roles/vega_core/tasks/health-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Download health-check binary
ansible.builtin.get_url:
force: true
url: "https://github.com/{{- vega_core_health_check_repository -}}/releases/download/{{- vega_core_health_check_version -}}/vega-health-check-linux-amd64"
dest: /usr/local/bin/vega-health-check
mode: '0755'

- name: Install health-check systemd
ansible.builtin.template:
src: "lib/systemd/system/vega-health-check.service.j2"
dest: "/lib/systemd/system/vega-health-check.service"
owner: "root"
group: "root"
mode: "0644"
notify: "Restart vega-health-check"
6 changes: 5 additions & 1 deletion roles/vega_core/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
when: vega_core_with_unsafe_reset_all

- name: Restart network
ansible.builtin.import_tasks: restart_network.yaml
ansible.builtin.import_tasks: restart-network.yaml

- name: Health-check setup
ansible.builtin.import_tasks: health-check.yaml
when: vega_core_with_health_check
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Unit]
Description=healthcheck
Documentation=https://github.com/vegaprotocol/ansible
After=network.target network-online.target
Requires=network-online.target

[Service]
User=vega
Group=vega
{% if vega_core_with_block_explorer | default(false) %}
ExecStart=/usr/local/bin/vega-health-check blockexplorer --blockexplorer-api-url "http://localhost:1515" --core-url "http://localhost:3003" --http-port 8080
{% elif vega_core_with_data_node | default(false) %}
ExecStart=/usr/local/bin/vega-health-check data-node --api-url "http://localhost:3008" --core-url "http://localhost:3003" --http-port 8080
{% else %}
ExecStart=/usr/local/bin/vega-health-check vega --core-url "http://localhost:3003" --http-port 8080
{% endif %}
TimeoutStopSec=10s
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
CPUQuota=10%

[Install]
WantedBy=multi-user.target

0 comments on commit bd5df72

Please sign in to comment.