fix(start-local): fix script exiting on pkill

pkill will exit failed if process is not found
pull/428/head
Adam Reese 9 years ago
parent 26999dca8c
commit 78d50da72c

@ -2,6 +2,11 @@
set -eo pipefail set -eo pipefail
[[ "$TRACE" ]] && set -x
HELM_ROOT="${BASH_SOURCE[0]%/*}/.."
source "$HELM_ROOT/scripts/common.sh"
KUBE_PROXY=${KUBE_PROXY:-} KUBE_PROXY=${KUBE_PROXY:-}
KUBE_PROXY_PORT=${KUBE_PROXY_PORT:-8001} KUBE_PROXY_PORT=${KUBE_PROXY_PORT:-8001}
MANAGER_PORT=${MANAGER_PORT:-8080} MANAGER_PORT=${MANAGER_PORT:-8080}
@ -10,20 +15,19 @@ RESOURCIFIER=bin/resourcifier
EXPANDYBIRD=bin/expandybird EXPANDYBIRD=bin/expandybird
MANAGER=bin/manager MANAGER=bin/manager
error_exit() {
# Display error message and exit
echo "error: ${1:-"unknown error"}" 1>&2
exit 1
}
require_binary_exists() { require_binary_exists() {
if ! command -v "$1" >/dev/null 2>&1; then if ! command -v "$1" >/dev/null 2>&1; then
error_exit "Cannot find binary for $1. Build binaries by running 'make build'" error_exit "Cannot find binary for $1. Build binaries by running 'make build'"
fi fi
} }
kill_service() {
pkill -f "$1" || true
}
for b in $RESOURCIFIER $EXPANDYBIRD $MANAGER; do for b in $RESOURCIFIER $EXPANDYBIRD $MANAGER; do
require_binary_exists $b require_binary_exists $b
kill_service $b
done done
LOGDIR=log LOGDIR=log
@ -34,15 +38,12 @@ fi
KUBECTL=$(which kubectl) || error_exit "Cannot find kubectl" KUBECTL=$(which kubectl) || error_exit "Cannot find kubectl"
echo "Starting resourcifier..." echo "Starting resourcifier..."
pkill -f $RESOURCIFIER
nohup $RESOURCIFIER > $LOGDIR/resourcifier.log 2>&1 --kubectl="${KUBECTL}" --port=8082 & nohup $RESOURCIFIER > $LOGDIR/resourcifier.log 2>&1 --kubectl="${KUBECTL}" --port=8082 &
echo "Starting expandybird..." echo "Starting expandybird..."
pkill -f $EXPANDYBIRD
nohup $EXPANDYBIRD > $LOGDIR/expandybird.log 2>&1 --port=8081 --expansion_binary=expansion/expansion.py & nohup $EXPANDYBIRD > $LOGDIR/expandybird.log 2>&1 --port=8081 --expansion_binary=expansion/expansion.py &
echo "Starting deployment manager..." 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 & nohup $MANAGER > $LOGDIR/manager.log 2>&1 --port="${MANAGER_PORT}" --kubectl="${KUBECTL}" --expanderURL=http://localhost:8081 --deployerURL=http://localhost:8082 &
if [[ "$KUBE_PROXY" ]]; then if [[ "$KUBE_PROXY" ]]; then

@ -2,23 +2,12 @@
echo "Stopping resourcifier..." echo "Stopping resourcifier..."
RESOURCIFIER=bin/resourcifier RESOURCIFIER=bin/resourcifier
if [[ ! -z $RESOURCIFIER ]] ; then pkill -f $RESOURCIFIER || echo "Resourcifier is not running"
pkill -f $RESOURCIFIER
fi
echo
echo "Stopping expandybird..." echo "Stopping expandybird..."
EXPANDYBIRD=bin/expandybird EXPANDYBIRD=bin/expandybird
if [[ ! -z $EXPANDYBIRD ]] ; then pkill -f $EXPANDYBIRD || echo "Expandybird is not running"
pkill -f $EXPANDYBIRD
fi
echo
echo "Stopping deployment manager..." echo "Stopping deployment manager..."
MANAGER=bin/manager MANAGER=bin/manager
if [[ ! -z $MANAGER ]] ; then pkill -f $MANAGER || echo "Manager is not running"
pkill -f $MANAGER
fi
echo
echo "Done."

Loading…
Cancel
Save