diff --git a/scripts/comm-dev.sh b/scripts/comm-dev.sh index 9197d0d80..5ff0dfa91 100755 --- a/scripts/comm-dev.sh +++ b/scripts/comm-dev.sh @@ -1,100 +1,100 @@ #! /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 " db - restart MariaDB server" echo "" exit 1 } services_usage() { echo "Comm Development Services" echo "" echo "Commands:" echo " restart - restart services" echo " start - start localstack and rabbitmq" echo " stop - stop localstack and rabbitmq" echo "" exit 1 } services_command() { case "$1" in restart) "$0" services stop || true "$0" services start ;; start) - nix run "$COMM_ROOT"#rabbitmq-up nix run "$COMM_ROOT"#localstack-up + nix run "$COMM_ROOT"#rabbitmq-up ;; stop) log "Stopping services" nix run "$COMM_ROOT"#localstack-down pkill rabbitmq-server beam.smp ;; *) log "$(basename "$0"): unknown services option '$1'" services_usage exit 1 ;; esac } db_usage() { echo "Comm MariaDB Server" echo "" echo "Commands:" echo " restart - restart MariaDB server" echo "" exit 1 } db_command() { case "$1" in restart) pkill mariadbd nix run .#mariadb-up ;; *) log "$(basename "$0"): unknown db option '$1'" db_usage exit 1 ;; esac } case "$1" in -h|--help) usage ;; services) shift services_command "$@" ;; db) shift db_command "$@" ;; *) log "$(basename "$0"): unknown option '$1'" usage ;; esac diff --git a/scripts/localstack_up.sh b/scripts/localstack_up.sh index 2b2da6079..2fd2492af 100644 --- a/scripts/localstack_up.sh +++ b/scripts/localstack_up.sh @@ -1,35 +1,41 @@ #!/usr/bin/env bash set -euo pipefail # Avoid localstack attempt to write in the nix store XDG_DATA_HOME=''${XDG_DATA_HOME:-$HOME/.local/share} export FILESYSTEM_ROOT=''${XDG_DATA_HOME}/localstack/filesystem # Since docker is installed outside of nix, need to ensure that it was # installed impurely if ! command -v docker > /dev/null; then echo "Please install docker in order to use localstack" >&2 exit 1 fi if ! command -v localstack > /dev/null; then echo "Please install localstack cli in order to use localstack" >&2 exit 1 fi +if [[ $(docker info 2>/dev/null) =~ "Cannot connect to the Docker" ]]; then + echo "Localstack requires Docker to be running" >&2 + echo "Please start Docker and try again" >&2 + exit 1 +fi + # The 'localstack status' command will poll forever if you have a newer # docker cli, so instead use docker ps + grep to determine running container if ! docker ps | grep localstack &> /dev/null; then echo "Starting localstack..." >&2 localstack start \ --detached \ --docker \ --no-banner > /dev/null else echo "localstack is already running, skipping localstack initialization" fi # Explicitly exit this script so the parent shell can determine # when it's safe to return control of terminal to user exit 0