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

Update to runTumblebug.sh and check readiness without auth #1559

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 43 additions & 12 deletions scripts/runTumblebug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,51 @@ cd "$parent_path"

# Get IP address which is accessable from outsite.
# `https://api.ipify.org` is one of IP lookup services. If it is not available we need to change.
echo "[Retrieve IP address that accessable from outside]"
echo
str=$(curl https://api.ipify.org)
if [ -z "$str" ]
then
echo "The result for IP lookup is empty."
echo "Set ENDPOINT=localhost"
str=localhost
echo "[Retrieve IP address accessible from outside]"
external_ip=$(curl -s https://api.ipify.org)

if [[ -n "$external_ip" ]]; then
# If external IP retrieval was successful, prompt user to select the ENDPOINT
echo "Please select endpoints to be used:"
echo "1) Use External IP for all components: $external_ip"
echo "2) Use 'host.docker.internal' to communicate with Spider and Dragonfly containers, 'localhost' for Tumblebug"
read -p "Enter your choice (1 or 2): " user_choice


case $user_choice in
1)
SP_ENDPOINT=$external_ip
DF_ENDPOINT=$external_ip
TB_ENDPOINT=$external_ip
;;
2)
SP_ENDPOINT="host.docker.internal"
DF_ENDPOINT="host.docker.internal"
TB_ENDPOINT="localhost"
;;
*)
echo "Invalid choice, use 'host.docker.internal' and 'localhost' as the default."
SP_ENDPOINT="host.docker.internal"
DF_ENDPOINT="host.docker.internal"
TB_ENDPOINT="localhost"
;;
esac
else
# If external IP retrieval failed, default to localhost
echo "Failed to retrieve external IP, use 'host.docker.internal' and 'localhost' as the default."
SP_ENDPOINT="host.docker.internal"
DF_ENDPOINT="host.docker.internal"
TB_ENDPOINT="localhost"
fi
ENDPOINT=$str

echo
echo "This script assume CB-Spider container is running in the same host. ($ENDPOINT)"
echo "This script assume CB-Spider container is running in the same host. ($external_ip)"
echo
CONTAINER_ENV="-e SPIDER_REST_URL=http://$ENDPOINT:1024/spider -e DRAGONFLY_REST_URL=http://$ENDPOINT:9090/dragonfly -e SELF_ENDPOINT=$ENDPOINT:1323"

./runContainer.sh "$CONTAINER_NAME_READ" "$CONTAINER_VERSION" "$CONTAINER_PORT" "$CONTAINER_DATA_PATH" "$CONTAINER_ENV"
if [ "$user_choice" != "1" ]; then
CONTAINER_ENV="--add-host host.docker.internal:host-gateway -e SPIDER_REST_URL=http://$SP_ENDPOINT:1024/spider -e DRAGONFLY_REST_URL=http://$DF_ENDPOINT:9090/dragonfly -e SELF_ENDPOINT=$TB_ENDPOINT:1323"
else
CONTAINER_ENV="-e SPIDER_REST_URL=http://$SP_ENDPOINT:1024/spider -e DRAGONFLY_REST_URL=http://$DF_ENDPOINT:9090/dragonfly -e SELF_ENDPOINT=$TB_ENDPOINT:1323"
fi

./runContainer.sh "$CONTAINER_NAME_READ" "$CONTAINER_VERSION" "$CONTAINER_PORT" "$CONTAINER_DATA_PATH" "$CONTAINER_ENV"
2 changes: 1 addition & 1 deletion src/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func RunServer(port string) {
if enableAuth {
e.Use(middleware.BasicAuthWithConfig(middleware.BasicAuthConfig{
Skipper: func(c echo.Context) bool {
if c.Path() == "/tumblebug/health" ||
if c.Path() == "/tumblebug/readyz" ||
c.Path() == "/tumblebug/httpVersion" {
return true
}
Expand Down