Skip to content

Commit 9e4a14b

Browse files
authored
Merge pull request #2858 from IntersectMBO/supervisord_unix_socket
feat: add supervisord unix socket support
2 parents dc7c990 + 92a6f9f commit 9e4a14b

File tree

10 files changed

+110
-59
lines changed

10 files changed

+110
-59
lines changed

cardano_node_tests/cluster_scripts/conway/start-cluster

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SCRIPT_DIR="$(readlink -m "${0%/*}")"
1616
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
1717
STATE_CLUSTER="${SOCKET_PATH%/*}"
1818
STATE_CLUSTER_NAME="${STATE_CLUSTER##*/}"
19+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
1920

2021
INSTANCE_NUM="%%INSTANCE_NUM%%"
2122
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
@@ -235,6 +236,15 @@ case "${UTXO_BACKEND:=""}" in
235236
;;
236237
esac
237238

239+
cat >> "${STATE_CLUSTER}/supervisor.conf" <<EoF
240+
241+
[unix_http_server]
242+
file = ${SUPERVISORD_SOCKET_PATH}
243+
244+
[supervisorctl]
245+
serverurl = unix:///${SUPERVISORD_SOCKET_PATH}
246+
EoF
247+
238248
# enable db-sync service
239249
if [ -n "${DBSYNC_REPO:-""}" ]; then
240250
[ -e "${DBSYNC_REPO}/db-sync-node/bin/cardano-db-sync" ] || \
@@ -656,9 +666,9 @@ for i in $(seq 1 "$NUM_DREPS"); do
656666
done
657667

658668
# create scripts for cluster starting / stopping
659-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start all" > "${STATE_CLUSTER}/supervisorctl_start"
660-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% restart nodes:" > "${STATE_CLUSTER}/supervisorctl_restart_nodes"
661-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% \"\$@\"" > "${STATE_CLUSTER}/supervisorctl"
669+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s start all" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl_start"
670+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s restart nodes:" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl_restart_nodes"
671+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s \"\$@\"" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl"
662672

663673
cat > "${STATE_CLUSTER}/supervisord_start" <<EoF
664674
#!/usr/bin/env bash
@@ -680,7 +690,7 @@ set -uo pipefail
680690
SCRIPT_DIR="\$(readlink -m "\${0%/*}")"
681691
PID_FILE="\${SCRIPT_DIR}/supervisord.pid"
682692
683-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
693+
supervisorctl -s unix:///${SUPERVISORD_SOCKET_PATH} stop all
684694
685695
if [ ! -f "\$PID_FILE" ]; then
686696
echo "Cluster is not running!"
@@ -765,7 +775,7 @@ SHELLEY_EPOCH="$(get_epoch)"
765775
# start db-sync
766776
if [ -n "${DBSYNC_REPO:-""}" ]; then
767777
echo "Starting db-sync"
768-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start dbsync
778+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start dbsync
769779
fi
770780

771781
sleep "$PROPOSAL_DELAY"
@@ -1009,7 +1019,7 @@ ALONZO_PV6_EPOCH="$(get_epoch)"
10091019
# start cardano-submit-api
10101020
if [ "$ENABLE_SUBMIT_API" -eq 1 ]; then
10111021
echo "Starting cardano-submit-api"
1012-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start submit_api
1022+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start submit_api
10131023
fi
10141024

10151025
cardano_cli_log alonzo query protocol-parameters \

cardano_node_tests/cluster_scripts/conway/stop-cluster

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ set -uo pipefail
55
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
66
STATE_CLUSTER="${SOCKET_PATH%/*}"
77
PID_FILE="${STATE_CLUSTER}/supervisord.pid"
8+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
89

910
INSTANCE_NUM="%%INSTANCE_NUM%%"
1011
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
1112
echo "CARDANO_NODE_SOCKET_PATH must be set to a path containing 'state-cluster${INSTANCE_NUM}', line $LINENO" >&2
1213
exit 1
1314
fi
1415

15-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
16+
if [ -e "$SUPERVISORD_SOCKET_PATH" ]; then
17+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" stop all
18+
fi
1619

1720
if [ ! -f "$PID_FILE" ]; then
1821
echo "Cluster is not running!"

cardano_node_tests/cluster_scripts/conway_fast/start-cluster

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SCRIPT_DIR="$(readlink -m "${0%/*}")"
1616
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
1717
STATE_CLUSTER="${SOCKET_PATH%/*}"
1818
STATE_CLUSTER_NAME="${STATE_CLUSTER##*/}"
19+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
1920

2021
INSTANCE_NUM="%%INSTANCE_NUM%%"
2122
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
@@ -174,6 +175,15 @@ case "${UTXO_BACKEND:=""}" in
174175
;;
175176
esac
176177

178+
cat >> "${STATE_CLUSTER}/supervisor.conf" <<EoF
179+
180+
[unix_http_server]
181+
file = ${SUPERVISORD_SOCKET_PATH}
182+
183+
[supervisorctl]
184+
serverurl = unix:///${SUPERVISORD_SOCKET_PATH}
185+
EoF
186+
177187
# enable db-sync service
178188
if [ -n "${DBSYNC_REPO:-""}" ]; then
179189
[ -e "${DBSYNC_REPO}/db-sync-node/bin/cardano-db-sync" ] || \
@@ -539,9 +549,9 @@ for i in $(seq 1 "$NUM_DREPS"); do
539549
done
540550

541551
# create scripts for cluster starting / stopping
542-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start all" > "${STATE_CLUSTER}/supervisorctl_start"
543-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% restart nodes:" > "${STATE_CLUSTER}/supervisorctl_restart_nodes"
544-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% \"\$@\"" > "${STATE_CLUSTER}/supervisorctl"
552+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s start all" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl_start"
553+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s restart nodes:" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl_restart_nodes"
554+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s \"\$@\"" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl"
545555

546556
cat > "${STATE_CLUSTER}/supervisord_start" <<EoF
547557
#!/usr/bin/env bash
@@ -563,7 +573,7 @@ set -uo pipefail
563573
SCRIPT_DIR="\$(readlink -m "\${0%/*}")"
564574
PID_FILE="\${SCRIPT_DIR}/supervisord.pid"
565575
566-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
576+
supervisorctl -s unix:///${SUPERVISORD_SOCKET_PATH} stop all
567577
568578
if [ ! -f "\$PID_FILE" ]; then
569579
echo "Cluster is not running!"
@@ -612,7 +622,7 @@ done
612622
# start db-sync
613623
if [ -n "${DBSYNC_REPO:-""}" ]; then
614624
echo "Starting db-sync"
615-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start dbsync
625+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start dbsync
616626
fi
617627

618628
echo "Sleeping for initial Tx submission delay of $TX_SUBMISSION_DELAY seconds"
@@ -719,7 +729,7 @@ cardano_cli_log conway transaction submit \
719729
# start cardano-submit-api
720730
if [ "$ENABLE_SUBMIT_API" -eq 1 ]; then
721731
echo "Starting cardano-submit-api"
722-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start submit_api
732+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start submit_api
723733
fi
724734

725735
sleep "$SUBMIT_DELAY"

cardano_node_tests/cluster_scripts/conway_fast/stop-cluster

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ set -uo pipefail
55
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
66
STATE_CLUSTER="${SOCKET_PATH%/*}"
77
PID_FILE="${STATE_CLUSTER}/supervisord.pid"
8+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
89

910
INSTANCE_NUM="%%INSTANCE_NUM%%"
1011
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
1112
echo "CARDANO_NODE_SOCKET_PATH must be set to a path containing 'state-cluster${INSTANCE_NUM}', line $LINENO" >&2
1213
exit 1
1314
fi
1415

15-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
16+
if [ -e "$SUPERVISORD_SOCKET_PATH" ]; then
17+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" stop all
18+
fi
1619

1720
if [ ! -f "$PID_FILE" ]; then
1821
echo "Cluster is not running!"

cardano_node_tests/cluster_scripts/mainnet_fast/start-cluster

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SCRIPT_DIR="$(readlink -m "${0%/*}")"
1616
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
1717
STATE_CLUSTER="${SOCKET_PATH%/*}"
1818
STATE_CLUSTER_NAME="${STATE_CLUSTER##*/}"
19+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
1920

2021
INSTANCE_NUM="%%INSTANCE_NUM%%"
2122
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
@@ -174,6 +175,15 @@ case "${UTXO_BACKEND:=""}" in
174175
;;
175176
esac
176177

178+
cat >> "${STATE_CLUSTER}/supervisor.conf" <<EoF
179+
180+
[unix_http_server]
181+
file = ${SUPERVISORD_SOCKET_PATH}
182+
183+
[supervisorctl]
184+
serverurl = unix:///${SUPERVISORD_SOCKET_PATH}
185+
EoF
186+
177187
# enable db-sync service
178188
if [ -n "${DBSYNC_REPO:-""}" ]; then
179189
[ -e "${DBSYNC_REPO}/db-sync-node/bin/cardano-db-sync" ] || \
@@ -539,9 +549,9 @@ for i in $(seq 1 "$NUM_DREPS"); do
539549
done
540550

541551
# create scripts for cluster starting / stopping
542-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start all" > "${STATE_CLUSTER}/supervisorctl_start"
543-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% restart nodes:" > "${STATE_CLUSTER}/supervisorctl_restart_nodes"
544-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% \"\$@\"" > "${STATE_CLUSTER}/supervisorctl"
552+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s start all" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl_start"
553+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s restart nodes:" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl_restart_nodes"
554+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s \"\$@\"" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl"
545555

546556
cat > "${STATE_CLUSTER}/supervisord_start" <<EoF
547557
#!/usr/bin/env bash
@@ -563,7 +573,7 @@ set -uo pipefail
563573
SCRIPT_DIR="\$(readlink -m "\${0%/*}")"
564574
PID_FILE="\${SCRIPT_DIR}/supervisord.pid"
565575
566-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
576+
supervisorctl -s unix:///${SUPERVISORD_SOCKET_PATH} stop all
567577
568578
if [ ! -f "\$PID_FILE" ]; then
569579
echo "Cluster is not running!"
@@ -612,7 +622,7 @@ done
612622
# start db-sync
613623
if [ -n "${DBSYNC_REPO:-""}" ]; then
614624
echo "Starting db-sync"
615-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start dbsync
625+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start dbsync
616626
fi
617627

618628
echo "Sleeping for initial Tx submission delay of $TX_SUBMISSION_DELAY seconds"
@@ -719,7 +729,7 @@ cardano_cli_log conway transaction submit \
719729
# start cardano-submit-api
720730
if [ "$ENABLE_SUBMIT_API" -eq 1 ]; then
721731
echo "Starting cardano-submit-api"
722-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start submit_api
732+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start submit_api
723733
fi
724734

725735
sleep "$SUBMIT_DELAY"

cardano_node_tests/cluster_scripts/mainnet_fast/stop-cluster

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ set -uo pipefail
55
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
66
STATE_CLUSTER="${SOCKET_PATH%/*}"
77
PID_FILE="${STATE_CLUSTER}/supervisord.pid"
8+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
89

910
INSTANCE_NUM="%%INSTANCE_NUM%%"
1011
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
1112
echo "CARDANO_NODE_SOCKET_PATH must be set to a path containing 'state-cluster${INSTANCE_NUM}', line $LINENO" >&2
1213
exit 1
1314
fi
1415

15-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
16+
if [ -e "$SUPERVISORD_SOCKET_PATH" ]; then
17+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" stop all
18+
fi
1619

1720
if [ ! -f "$PID_FILE" ]; then
1821
echo "Cluster is not running!"

cardano_node_tests/cluster_scripts/testnets/start-cluster

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SCRIPT_DIR="$(readlink -m "${0%/*}")"
77
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
88
STATE_CLUSTER="${SOCKET_PATH%/*}"
99
STATE_CLUSTER_NAME="${STATE_CLUSTER##*/}"
10+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
1011

1112
INSTANCE_NUM="%%INSTANCE_NUM%%"
1213
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
@@ -55,6 +56,15 @@ jq --arg ekg "$RELAY1_EKG" --arg prometheus "$RELAY1_PROMETHEUS" \
5556
"$TESTNET_CONF_DIR/config-relay1.json" > "$STATE_CLUSTER/config-relay1.json"
5657
chmod u+w "$STATE_CLUSTER"/config-*.json
5758

59+
cat >> "${STATE_CLUSTER}/supervisor.conf" <<EoF
60+
61+
[unix_http_server]
62+
file = ${SUPERVISORD_SOCKET_PATH}
63+
64+
[supervisorctl]
65+
serverurl = unix:///${SUPERVISORD_SOCKET_PATH}
66+
EoF
67+
5868
# enable db-sync service
5969
if [ -n "${DBSYNC_REPO:-""}" ]; then
6070
[ -e "$DBSYNC_REPO/db-sync-node/bin/cardano-db-sync" ] || \
@@ -96,8 +106,8 @@ EoF
96106
fi
97107

98108
# create scripts for cluster starting / stopping
99-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start all" > "$STATE_CLUSTER/supervisorctl_start"
100-
printf "#!/bin/sh\n\nsupervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% \"\$@\"" > "$STATE_CLUSTER/supervisorctl"
109+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s start all" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl_start"
110+
printf "#!/bin/sh\n\nsupervisorctl -s unix:///%s \"\$@\"" "$SUPERVISORD_SOCKET_PATH" > "${STATE_CLUSTER}/supervisorctl"
101111

102112
cat > "$STATE_CLUSTER/supervisord_start" <<EoF
103113
#!/usr/bin/env bash
@@ -119,7 +129,7 @@ set -uo pipefail
119129
SCRIPT_DIR="\$(readlink -m "\${0%/*}")"
120130
PID_FILE="\$SCRIPT_DIR/supervisord.pid"
121131
122-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
132+
supervisorctl -s unix:///${SUPERVISORD_SOCKET_PATH} stop all
123133
124134
if [ ! -f "\$PID_FILE" ]; then
125135
echo "Cluster is not running!"
@@ -177,13 +187,13 @@ done
177187
# start cardano-submit-api
178188
if command -v cardano-submit-api >/dev/null 2>&1 && [ -e "$STATE_CLUSTER/submit-api-config.json" ]; then
179189
echo "Starting cardano-submit-api"
180-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start submit_api
190+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start submit_api
181191
fi
182192

183193
# start db-sync
184194
if [ -n "${DBSYNC_REPO:-""}" ]; then
185195
echo "Starting db-sync"
186-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start dbsync
196+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" start dbsync
187197
sleep 10
188198

189199
echo "Waiting to make sure db-sync is synced"

cardano_node_tests/cluster_scripts/testnets/stop-cluster

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ set -uo pipefail
55
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
66
STATE_CLUSTER="${SOCKET_PATH%/*}"
77
PID_FILE="${STATE_CLUSTER}/supervisord.pid"
8+
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
89

910
INSTANCE_NUM="%%INSTANCE_NUM%%"
1011
if [[ "$SOCKET_PATH" != *"/state-cluster${INSTANCE_NUM}/"* ]]; then
1112
echo "CARDANO_NODE_SOCKET_PATH must be set to a path containing 'state-cluster${INSTANCE_NUM}', line $LINENO" >&2
1213
exit 1
1314
fi
1415

15-
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% stop all
16+
if [ -e "$SUPERVISORD_SOCKET_PATH" ]; then
17+
supervisorctl -s "unix:///${SUPERVISORD_SOCKET_PATH}" stop all
18+
fi
1619

1720
if [ ! -f "$PID_FILE" ]; then
1821
echo "Cluster is not running!"

0 commit comments

Comments
 (0)