Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification Missing Function Call #43

Open
velterity opened this issue Sep 23, 2024 · 0 comments
Open

Notification Missing Function Call #43

velterity opened this issue Sep 23, 2024 · 0 comments

Comments

@velterity
Copy link

velterity commented Sep 23, 2024

The notification-test script is missing the call of the function get_container_id.

When you run this script you always get:

"notification container is not running. Please start it first"

I noticed the script never calls get_container_id to get the container_id after the function was declared. Also, localhost is wrong since swarm isn't exposing locally on the host(at least wasnt for me). It should be the container name of the microservice, which changes every time it's restarted:

I think if you were to add another function which gets that name and passes to the docker exec, should fix this:

function get_container_name() {
CONTAINER_NAME=$(docker ps --filter "name=voinetwork_notify" --format "{{.Names}}")
}

docker exec -it "${CONTAINER_ID}" bash -c "curl -sS -X POST --data '{"title": "Voi Participation Key Notification Test", "body": "Notification test for Voi Network"}' ${CONTAINER_NAME}:5000 >> /dev/null && echo "Notification sent""

So something similar could be added

#!/bin/bash

source "${HOME}/voi/bin/.helpers/util.sh"

CONTAINER_ID=""
CONTAINER_NAME=""

function get_container_id() {
  CONTAINER_ID=$(docker ps -q -f name=voinetwork_algod)
}

function get_container_name() {
  CONTAINER_NAME=$(docker ps --filter "name=voinetwork_notify" --format "{{.Names}}")
}

function validate_supported_node_type() {
  if [[ ${VOINETWORK_PROFILE} != "participation" ]]; then
    util_abort "This operation is only supported for participation nodes. Exiting the program."
  fi
}

validate_supported_node_type
get_container_id
get_container_name

if [ -z "${CONTAINER_ID}" ]; then
    echo "notification container is not running. Please start it first."
    exit 1
fi

echo "Sending notification"
docker exec -it "${CONTAINER_ID}" bash -c "curl -sS -X POST --data '{\"title\": \"Voi Participation Key Notification Test\", \"body\": \"Notification test for Voi Network\"}' ${CONTAINER_NAME}:5000 >> /dev/null && echo \"Notification sent\""

echo "Note: After making changes to your notification.yml settings file, make sure to rerun the install script."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant