lmjtfy.git / tools / stop-dev.sh
1#!/usr/bin/env bash
2# Stop the dev server before a deploy, which builds into the same build/.
3#
4#     tools/stop-dev.sh
5#
6# `mise daemons stop worker` fails with "no matching project daemons" when the
7# daemon has never been started on this machine (mise lists it as `available`),
8# and a deploy from such a machine is the ordinary case. So: nothing to stop
9# is not an error; a daemon that is there and will not stop is.
10set -euo pipefail
11cd "$(dirname "$0")/.."
12state="$(mise daemons ls 2>/dev/null | awk '$1 ~ /\/worker$/ { print $2 }')"
13case "$state" in
14  "" | available) exit 0 ;;
15  *) exec mise daemons stop worker ;;
16esac