Skip to content

Commit 6367aac

Browse files
authored
Merge pull request #332 from cipherstash/fix/print-error-on-pstgres-not-running
fix: show error from mise task when postgres is not running
2 parents b293cf8 + e445625 commit 6367aac

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

mise.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,20 @@ mise run build:binary --target {{target}}
7676
# build a new container
7777
mise run build:docker --platform {{docker_platform}}
7878
79-
8079
# Make the default invocation with `mise run proxy:up` work.
8180
# The default mise environment configuration works for Proxy running as a process, connecting via a port forward.
8281
# Try detecting a running postgres, and use it
8382
if [ "${CS_DATABASE__HOST}" == "localhost" ]; then
8483
{% raw %}
85-
running_postgres="$(docker ps --filter "name=postgres" --filter "health=healthy" --format "{{.Names}};{{.Ports}}" | grep ${CS_DATABASE__PORT})"
84+
running_postgres="$(docker ps --filter "name=postgres" --filter "health=healthy" --format "{{.Names}};{{.Ports}}")"
8685
{% endraw %}
87-
if [ -z "${running_postgres}" ]; then
86+
if [ -z "${running_postgres}" ] || [ -z $(echo ${running_postgres} | grep ${CS_DATABASE__PORT}) ] ; then
8887
echo "error: Could not detect a running, healthy postgres container with port ${CS_DATABASE__PORT}"
8988
echo "error: Try running 'mise run postgres:up' to start a container"
9089
exit 68
9190
fi
9291
echo $running_postgres
93-
export CS_DATABASE__HOST=$(echo $running_postgres | cut -d ';' -f 1)
92+
export CS_DATABASE__HOST=$(echo $running_postgres | grep ${CS_DATABASE__PORT} | cut -d ';' -f 1)
9493
echo "Using postgres running in container: ${CS_DATABASE__HOST}"
9594
fi
9695

0 commit comments

Comments
 (0)