From bd4723548a699ffbd77576b0e16ccea0e086ae13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 24 Nov 2020 15:37:01 +0100 Subject: [PATCH] allow enabling websocket API port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- defaults/main.yml | 4 ++++ tasks/consul.yml | 12 ++++++++++++ tasks/container.yml | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 9ce4e66..cdf205d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,6 +29,10 @@ geth_rpc_port: 8545 geth_rcp_api: 'eth,net,web3,personal,admin' # Alternative IPC socket geth_ipc_path: '/data/geth.ipc' +# Web Sockets API +geth_websocket_enabled: true +geth_websocket_port: '{{ geth_rpc_port + 1 | int }}' +geth_websocket_api: 'eth,net,web3,personal,admin' # useful for linking containers geth_extra_alias: geth geth_aliases: diff --git a/tasks/consul.yml b/tasks/consul.yml index 9b33ee0..dea75a8 100644 --- a/tasks/consul.yml +++ b/tasks/consul.yml @@ -45,3 +45,15 @@ type: script script: '{{ geth_sync_check_script }}' timeout: '5s' + - name: '{{ geth_cont_name }}-ws' + tags: '{{ geth_consul_tags + ["websocket"] }}' + port: '{{ geth_websocket_port }}' + address: '{{ geth_consul_rpc_address }}' + meta: + env: '{{ env }}' + stage: '{{ stage }}' + checks: + - id: '{{ geth_cont_name }}-ws-status' + name: 'Geth WebSocket API' + type: 'tcp' + tcp: 'localhost:{{ geth_websocket_port }}' diff --git a/tasks/container.yml b/tasks/container.yml index 14cceef..2cca1b7 100644 --- a/tasks/container.yml +++ b/tasks/container.yml @@ -15,6 +15,7 @@ ports: - '{{ geth_port }}:{{ geth_port }}/tcp' - '{{ geth_port }}:{{ geth_port }}/udp' + - '{{ geth_websocket_port }}:{{ geth_websocket_port }}/tcp' - '{{ geth_rpc_addr }}:{{ geth_rpc_port }}:{{ geth_rpc_port }}' labels: # These are just for documentation @@ -65,6 +66,13 @@ --http.api={{ geth_rcp_api }} --ipcpath={{ geth_ipc_path }} {% endif %} + {% if geth_websocket_enabled %} + --ws + --ws.addr=0.0.0.0 + --ws.port={{ geth_websocket_port }} + --ws.origins={{ geth_aliases | join(",") }} + --ws.api={{ geth_websocket_api }} + {% endif %} volumes: - '{{ geth_cont_vol }}/keys:/keys:rw' # WARNING: This assumes /data is mounted, see bootstrap role