From cb0b393efb731a25a98fa04f1f577cb7753a2c4b Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Thu, 16 May 2024 21:48:39 +0200 Subject: [PATCH] Deafult run.cmd to not include monitoring, flag for monitoring profile --- README.md | 6 ++++++ scripts/run.ps1 | 20 +++++++++++++++++--- scripts/run.sh | 24 +++++++++++++++++++----- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 56b838f6..9290e44f 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,12 @@ Either docker or podman must be installed. ./run.cmd ``` +Optionally, if you want access to Grafana and a local monitoring setup based on OpenTelemetry: + +```shell +./run.cmd -m +``` + If the localtest setup is already running, it will restart. To stop localtest diff --git a/scripts/run.ps1 b/scripts/run.ps1 index 517da21a..ba502a68 100755 --- a/scripts/run.ps1 +++ b/scripts/run.ps1 @@ -1,5 +1,17 @@ #!/usr/bin/env pwsh +param( + [Parameter(HelpMessage="")] + [switch]$m = $False, +) + +$Profile = "" + +if ($m) +{ + $Profile = "--profile ""monitoring""" +} + if ($args[0] -eq "stop") { Write-Host "Stopping localtest!" @@ -25,6 +37,7 @@ if ($args[0] -eq "stop") else { Write-host "Preqreqs missing - please install docker or podman" + exit 1 } } else @@ -35,7 +48,7 @@ else { Write-host "Running using docker" docker compose --profile "*" down -v - docker compose --profile "*" up -d --build + iex "docker compose $Profile -d --build" } elseif (Get-Command "docker-compose" -errorAction SilentlyContinue) { @@ -44,16 +57,17 @@ else # whereas podman-compose has only recently added support, and not many users have the latest versions Write-host "Running using docker-compose" docker-compose --file podman-compose.yml --profile "*" down -v - docker-compose --file podman-compose.yml --profile "*" up -d --build + iex "docker-compose --file podman-compose.yml $Profile -d --build" } elseif (Get-Command "podman" -errorAction SilentlyContinue) { Write-host "Running using podman" podman compose --file podman-compose.yml --profile "*" down -v - podman compose --file podman-compose.yml --profile "*" up -d --build + iex "podman compose --file podman-compose.yml $Profile -d --build" } else { Write-host "Preqreqs missing - please install docker or podman" + exit 1 } } diff --git a/scripts/run.sh b/scripts/run.sh index e34c9119..4a374f22 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,8 +1,22 @@ #!/usr/bin/env sh -set -ex +set -e -if [ $1 = "stop" ]; then +include_monitoring=false +while getopts "m" flag; do + case "${flag}" in + m) include_monitoring=true ;; + \?) exit 1 ;; + esac +done +shift $((${OPTIND} - 1)) + +profile="" +if [ "$include_monitoring" = true ]; then + profile="--profile \"monitoring\"" +fi + +if [ "$1" = "stop" ]; then echo "Stopping localtest!" if [ -x "$(command -v docker)" ]; then echo "Stopping using docker" @@ -25,18 +39,18 @@ else if [ -x "$(command -v docker)" ]; then echo "Running using docker" docker compose --profile "*" down -v - docker compose --profile "*" up -d --build + eval "docker compose $profile up -d --build" elif [ -x "$(command -v docker-compose)" ]; then # If the user is not using docker, there should be podman installed # If additionally docker-compose is installed, we use that since it has had '--profile' support for a long time, # whereas podman-compose has only recently added support, and not many users have the latest versions echo "Running using docker-compose" docker-compose --file podman-compose.yml --profile "*" down -v - docker-compose --file podman-compose.yml --profile "*" up -d --build + eval "docker-compose --file podman-compose.yml $profile up -d --build" elif [ -x "$(command -v podman)" ]; then echo "Running using podman" podman compose --file podman-compose.yml --profile "*" down -v - podman compose --file podman-compose.yml --profile "*" up -d --build + eval "podman compose --file podman-compose.yml $profile up -d --build" else echo "Preqreqs missing - please install docker or podman" exit 1