Skip to content

Commit

Permalink
Added status command to the script
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Feb 24, 2023
1 parent b6cf09e commit fe9a570
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion scripts/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ function help {
echo " attach Attach to the already running node"
echo " help Print the help message"
echo " init Initialize the configuration"
echo " setup Install the dependencies and setup the requirements"
echo " setup Install the dependencies and set up the requirements"
echo " start Start the node"
echo " status Display the node's status along with the last 20 lines of the log"
echo " stop Stop the node"
echo " remove Remove the node container"
echo " restart Restart the node"
Expand Down Expand Up @@ -494,6 +495,22 @@ function start {
fi
}

function status {
id=$(docker ps --all --filter name="${CONTAINER_NAME}" --quiet)
if [[ -n "${id}" ]]; then
running=$(docker container inspect --format "{{ .State.Running }}" "${CONTAINER_NAME}")
if [[ "${running}" == "true" ]]; then
echo "Node is running..."
else
exit_code=$(docker container inspect --format "{{ .State.ExitCode }}" "${CONTAINER_NAME}")
echo "Node is not running and has exited with code ${exit_code}"
fi
docker logs --details --tail 20 "${CONTAINER_NAME}"
else
echo "Error: node container does not exist"
fi
}

function stop {
id=$(docker ps --all --filter name="${CONTAINER_NAME}" --quiet)
if [[ -n "${id}" ]]; then
Expand Down Expand Up @@ -566,6 +583,10 @@ case "${1}" in
shift
start "${@}"
;;
"status")
shift
status "${@}"
;;
"stop")
shift
stop "${@}"
Expand Down

0 comments on commit fe9a570

Please sign in to comment.