Skip to content

Commit

Permalink
haproxy: add eth-jsonrpc and eth-jsonrpcws for needed chains (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
baabeetaa authored Jun 4, 2023
1 parent e640a2f commit 06983f4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
1 change: 0 additions & 1 deletion load_balancer/caddy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pacman -S --noconfirm base-devel jq dnsutils python caddy screen wget cronie

# write env vars to bash file, so that cronjobs or other scripts could know
cat <<EOT >> $HOME/env.sh
CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL"
CONFIG_FILE="/etc/caddy/Caddyfile"
TMP_CONFIG_FILE="/etc/caddy/Caddyfile.tmp"
rpc_service_name="$rpc_service_name"
Expand Down
40 changes: 40 additions & 0 deletions load_balancer/haproxy/haproxy.eth.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# to be append to haproxy.cfg for needed chains

frontend fe_eth
bind :8004
mode http
log global
option httplog
option dontlognull
option forwardfor except 127.0.0.0/8

default_backend be_eth


frontend fe_ethws
bind :8005
mode http
log global
option httplog
option dontlognull
option forwardfor except 127.0.0.0/8

default_backend be_ethws


backend be_eth
mode http
balance roundrobin
option httpchk
http-check connect proto h1
http-check send meth GET uri /healthcheck
server-template st 3 tasks.${rpc_service_name}:8545 check port 80 inter 10s weight 1 resolvers ns init-addr none


backend be_ethws
mode http
balance roundrobin
option httpchk
http-check connect proto h1
http-check send meth GET uri /healthcheck
server-template st 3 tasks.${rpc_service_name}:8546 check port 80 inter 10s weight 1 resolvers ns init-addr none
8 changes: 7 additions & 1 deletion load_balancer/haproxy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pacman -S --noconfirm base-devel jq dnsutils python haproxy screen wget cronie

# write env vars to bash file, so that cronjobs or other scripts could know
cat <<EOT >> $HOME/env.sh
CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL"
rpc_service_name="$rpc_service_name"
EOT

Expand All @@ -25,6 +24,13 @@ source $HOME/env.sh
# haproxy

curl -Ls "https://raw.githubusercontent.com/notional-labs/cosmosia/main/load_balancer/haproxy/haproxy.cfg" > $HOME/haproxy.cfg

# enable eth for needed chains by appending haproxy.eth.cfg to haproxy.cfg
if [[ $rpc_service_name == rpc_evmos* ]]; then
curl -Ls "https://raw.githubusercontent.com/notional-labs/cosmosia/main/load_balancer/haproxy/haproxy.eth.cfg" >> $HOME/haproxy.cfg
fi


curl -Ls "https://raw.githubusercontent.com/notional-labs/cosmosia/main/load_balancer/haproxy/start.sh" > $HOME/start.sh
curl -Ls "https://raw.githubusercontent.com/notional-labs/cosmosia/main/load_balancer/haproxy/reload.sh" > $HOME/reload.sh

Expand Down

0 comments on commit 06983f4

Please sign in to comment.