Inform user about weave containers in state 'restarting'

This commit is contained in:
Bryan Boreham committed 2015-12-22 13:01:00 +00:00
1 parent abf1db0045
commit 73e0a6bb0a
1 file changed
+26 -18
+26 -18
View File
@@ -906,29 +906,37 @@ container_weave_addrs() {
# functions for interacting with containers
######################################################################
# Check that a container named $1 with image $2 is not running
# Check that a container for component $1 named $2 with image $3 is not running
check_not_running() {
case $(docker inspect --format='{{.State.Running}} {{.Config.Image}}' $1 2>/dev/null) in
"true $2")
echo "$1 is already running." >&2
case $(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $2 2>/dev/null) in
"true restarting $3")
echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2
exit 1
;;
"true $2:"*)
echo "$1 is already running." >&2
"true restarting $3:"*)
echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2
exit 1
;;
"false $2")
docker rm $1 >/dev/null
"true "*" $3")
echo "$2 is already running." >&2
exit 1
;;
"false $2:"*)
docker rm $1 >/dev/null
"true "*" $3:"*)
echo "$2 is already running." >&2
exit 1
;;
"false "*" $3")
docker rm $2 >/dev/null
;;
"false "*" $3:"*)
docker rm $2 >/dev/null
;;
true*)
echo "Found another running container named '$1'. Aborting." >&2
echo "Found another running container named '$2'. Aborting." >&2
exit 1
;;
false*)
echo "Found another container named '$1'. Aborting." >&2
echo "Found another container named '$2'. Aborting." >&2
exit 1
;;
esac
@@ -1843,9 +1851,9 @@ EOF
;;
launch)
deprecation_warnings "$@"
check_not_running $CONTAINER_NAME $BASE_IMAGE
check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
check_not_running $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE
check_not_running router $CONTAINER_NAME $BASE_IMAGE
check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
check_not_running plugin $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE
COMMON_ARGS=$(common_launch_args "$@")
launch_router "$@"
launch_proxy $COMMON_ARGS
@@ -1853,7 +1861,7 @@ EOF
;;
launch-router)
deprecation_warnings "$@"
check_not_running $CONTAINER_NAME $BASE_IMAGE
check_not_running router $CONTAINER_NAME $BASE_IMAGE
launch_router "$@"
echo $ROUTER_CONTAINER
;;
@@ -1867,12 +1875,12 @@ EOF
;;
launch-proxy)
deprecation_warnings "$@"
check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
launch_proxy "$@"
echo $PROXY_CONTAINER
;;
launch-plugin)
check_not_running $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE
check_not_running plugin $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE
launch_plugin "$@"
echo $PLUGIN_CONTAINER
;;