Skip to content

Commit

Permalink
Add default values for SOCKET and improve offline mode (#719)
Browse files Browse the repository at this point in the history
* env: Add default value for CARDANO_NODE_SOCKET_PATH for Offline Mode
* env: Throw an error for missing CONFIG for offline mode
* cnode.sh: Replace SOCKET with CARDANO_NODE_SOCKET_PATH
* cnode.sh: Indentation
  • Loading branch information
rdlrt committed Jan 14, 2021
1 parent 6ebaefa commit 6fd782d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 8 additions & 8 deletions scripts/cnode-helper-scripts/cnode.sh
Expand Up @@ -17,13 +17,13 @@
# Do NOT modify code below #
######################################

if [[ -S "${SOCKET}" ]]; then
if pgrep -f "[c]ardano-node.*.${SOCKET}"; then
if [[ -S "${CARDANO_NODE_SOCKET_PATH}" ]]; then
if pgrep -f "[c]ardano-node.*.${CARDANO_NODE_SOCKET_PATH}"; then
echo "ERROR: A Cardano node is already running, please terminate this node before starting a new one with this script."
exit 1
else
echo "WARN: A prior running Cardano node was not cleanly shutdown, socket file still exists. Cleaning up."
unlink "${SOCKET}"
unlink "${CARDANO_NODE_SOCKET_PATH}"
fi
fi

Expand All @@ -36,18 +36,18 @@ if [[ -f "${POOL_DIR}/${POOL_OPCERT_FILENAME}" && -f "${POOL_DIR}/${POOL_VRF_SK_
--topology "${TOPOLOGY}" \
--config "${CONFIG}" \
--database-path "${DB_DIR}" \
--socket-path "${SOCKET}" \
--socket-path "${CARDANO_NODE_SOCKET_PATH}" \
--host-addr 0.0.0.0 \
--shelley-kes-key "${POOL_DIR}/${POOL_HOTKEY_SK_FILENAME}" \
--shelley-vrf-key "${POOL_DIR}/${POOL_VRF_SK_FILENAME}" \
--shelley-operational-certificate "${POOL_DIR}/${POOL_OPCERT_FILENAME}" \
--shelley-kes-key "${POOL_DIR}/${POOL_HOTKEY_SK_FILENAME}" \
--shelley-vrf-key "${POOL_DIR}/${POOL_VRF_SK_FILENAME}" \
--shelley-operational-certificate "${POOL_DIR}/${POOL_OPCERT_FILENAME}" \
--port ${CNODE_PORT}
else
cardano-node run \
--topology "${TOPOLOGY}" \
--config "${CONFIG}" \
--database-path "${DB_DIR}" \
--socket-path "${SOCKET}" \
--socket-path "${CARDANO_NODE_SOCKET_PATH}" \
--host-addr 0.0.0.0 \
--port ${CNODE_PORT}
fi
6 changes: 4 additions & 2 deletions scripts/cnode-helper-scripts/env
Expand Up @@ -116,7 +116,9 @@ fi
if [[ -z "${SOCKET}" ]]; then
if [[ "$(ps -ef | grep "[c]ardano-node.*.port ${CNODE_PORT}")" =~ --socket-path[[:space:]]([^[:space:]]+) ]]; then
export CARDANO_NODE_SOCKET_PATH="${BASH_REMATCH[1]}"
elif [[ ${OFFLINE_MODE} = "N" && -z "${CARDANO_NODE_SOCKET_PATH}" ]]; then
elif [[ ${OFFLINE_MODE} = "Y" ]]; then
export CARDANO_NODE_SOCKET_PATH="${CNODE_HOME}/sockets/node0.socket"
else
echo "Node socket not set in env file and automatic detection failed! [source: $(basename $0 2>/dev/null)]"
return 1
fi
Expand All @@ -129,7 +131,7 @@ if [[ -z "${CONFIG}" ]]; then
CONFIG=${BASH_REMATCH[1]}
elif [[ -f "${CNODE_HOME}/files/config.json" ]]; then
CONFIG="${CNODE_HOME}/files/config.json"
elif [[ ${OFFLINE_MODE} = "N" ]]; then
else
echo "Node config not set in env file and automatic detection failed!"
return 1
fi
Expand Down

0 comments on commit 6fd782d

Please sign in to comment.