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

feat: add health-check to all nodes #16

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading