From 78d50da72c46b0f725d2c8aa17d56090f7951f82 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 21 Mar 2016 18:23:33 -0700 Subject: [PATCH] fix(start-local): fix script exiting on pkill pkill will exit failed if process is not found --- scripts/start-local.sh | 19 ++++++++++--------- scripts/stop-local.sh | 17 +++-------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/scripts/start-local.sh b/scripts/start-local.sh index 14fe39308..db8c5fa0d 100755 --- a/scripts/start-local.sh +++ b/scripts/start-local.sh @@ -2,6 +2,11 @@ set -eo pipefail +[[ "$TRACE" ]] && set -x + +HELM_ROOT="${BASH_SOURCE[0]%/*}/.." +source "$HELM_ROOT/scripts/common.sh" + KUBE_PROXY=${KUBE_PROXY:-} KUBE_PROXY_PORT=${KUBE_PROXY_PORT:-8001} MANAGER_PORT=${MANAGER_PORT:-8080} @@ -10,20 +15,19 @@ RESOURCIFIER=bin/resourcifier EXPANDYBIRD=bin/expandybird MANAGER=bin/manager -error_exit() { - # Display error message and exit - echo "error: ${1:-"unknown error"}" 1>&2 - exit 1 -} - require_binary_exists() { if ! command -v "$1" >/dev/null 2>&1; then error_exit "Cannot find binary for $1. Build binaries by running 'make build'" fi } +kill_service() { + pkill -f "$1" || true +} + for b in $RESOURCIFIER $EXPANDYBIRD $MANAGER; do require_binary_exists $b + kill_service $b done LOGDIR=log @@ -34,15 +38,12 @@ fi KUBECTL=$(which kubectl) || error_exit "Cannot find kubectl" echo "Starting resourcifier..." -pkill -f $RESOURCIFIER nohup $RESOURCIFIER > $LOGDIR/resourcifier.log 2>&1 --kubectl="${KUBECTL}" --port=8082 & echo "Starting expandybird..." -pkill -f $EXPANDYBIRD nohup $EXPANDYBIRD > $LOGDIR/expandybird.log 2>&1 --port=8081 --expansion_binary=expansion/expansion.py & echo "Starting deployment manager..." -pkill -f $MANAGER nohup $MANAGER > $LOGDIR/manager.log 2>&1 --port="${MANAGER_PORT}" --kubectl="${KUBECTL}" --expanderURL=http://localhost:8081 --deployerURL=http://localhost:8082 & if [[ "$KUBE_PROXY" ]]; then diff --git a/scripts/stop-local.sh b/scripts/stop-local.sh index 70a092ef2..12ea5a45d 100755 --- a/scripts/stop-local.sh +++ b/scripts/stop-local.sh @@ -2,23 +2,12 @@ echo "Stopping resourcifier..." RESOURCIFIER=bin/resourcifier -if [[ ! -z $RESOURCIFIER ]] ; then - pkill -f $RESOURCIFIER -fi -echo +pkill -f $RESOURCIFIER || echo "Resourcifier is not running" echo "Stopping expandybird..." EXPANDYBIRD=bin/expandybird -if [[ ! -z $EXPANDYBIRD ]] ; then - pkill -f $EXPANDYBIRD -fi -echo +pkill -f $EXPANDYBIRD || echo "Expandybird is not running" echo "Stopping deployment manager..." MANAGER=bin/manager -if [[ ! -z $MANAGER ]] ; then - pkill -f $MANAGER -fi -echo - -echo "Done." +pkill -f $MANAGER || echo "Manager is not running"