diff --git a/scripts/bin/comm-dev b/scripts/bin/comm-dev new file mode 100755 --- /dev/null +++ b/scripts/bin/comm-dev @@ -0,0 +1,7 @@ +#! /usr/bin/env bash + +# This is a command entrypoint so that the majority of the bash +# code can be linted by shellcheck + +PRJ_ROOT=$(git rev-parse --show-toplevel) +"$PRJ_ROOT"/scripts/comm-dev.sh $@ diff --git a/scripts/comm-dev.sh b/scripts/comm-dev.sh new file mode 100755 --- /dev/null +++ b/scripts/comm-dev.sh @@ -0,0 +1,69 @@ +#! /usr/bin/env bash + +# This is an entry for common development workflows like starting and stopping +# expensive services + +set -euo pipefail + +COMM_ROOT="$(git rev-parse --show-toplevel)" + +log() { + echo "$@" >&2 +} + +usage() { + echo "Comm Development" + echo "" + echo "Commands:" + echo " services - start or stop development services" + echo "" + + exit 1 +} + +services_usage() { + echo "Comm Development Services" + echo "" + echo "Commands:" + echo " restart - restart services" + echo " start - start rabbitmq" + echo " stop - stop rabbitmq" + echo "" + + exit 1 +} + +services_command() { + case "$1" in + restart) + "$0" services stop || true + "$0" services start + ;; + start) + nix run "$COMM_ROOT"#rabbitmq-up + ;; + stop) + log "Stopping services" + pkill rabbitmq-server beam.smp + ;; + *) + log "$(basename "$0"): unknown services option '$1'" + services_usage + exit 1 + ;; + esac +} + +case "$1" in + -h|--help) + usage + ;; + services) + shift + services_command "$@" + ;; + *) + log "$(basename "$0"): unknown option '$1'" + usage + ;; +esac diff --git a/scripts/source_development_defaults.sh b/scripts/source_development_defaults.sh --- a/scripts/source_development_defaults.sh +++ b/scripts/source_development_defaults.sh @@ -32,6 +32,10 @@ export PATH="$PATH":./node_modules/.bin +# Development helpers +PRJ_ROOT="$(git rev-parse --show-toplevel)" +export PATH="$PATH":${PRJ_ROOT}/scripts/bin + # mysql2 package wants stable prefixes for temporary directory paths # 'nix develop' will set TMP and related variables to something different each # invocation