Merge pull request #1886 from weaveworks/issues/1869-leave-plugin
Allow plugin to keep running on 'weave launch'
This commit is contained in:
commit
b3a29bec1b
1 file changed
+15
-9
@@ -909,22 +909,22 @@ check_not_running() {
|
|||||||
case ${RUN_STATUS%:*} in
|
case ${RUN_STATUS%:*} in
|
||||||
"true restarting $3")
|
"true restarting $3")
|
||||||
echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2
|
echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2
|
||||||
exit 1
|
return 3
|
||||||
;;
|
;;
|
||||||
"true "*" $3")
|
"true "*" $3")
|
||||||
echo "$2 is already running; you can stop it with 'weave stop-$1'." >&2
|
echo "$2 is already running; you can stop it with 'weave stop-$1'." >&2
|
||||||
exit 1
|
return 1
|
||||||
;;
|
;;
|
||||||
"false "*" $3")
|
"false "*" $3")
|
||||||
docker rm $2 >/dev/null
|
docker rm $2 >/dev/null
|
||||||
;;
|
;;
|
||||||
true*)
|
true*)
|
||||||
echo "Found another running container named '$2'. Aborting." >&2
|
echo "Found another running container named '$2'. Aborting." >&2
|
||||||
exit 1
|
return 2
|
||||||
;;
|
;;
|
||||||
false*)
|
false*)
|
||||||
echo "Found another container named '$2'. Aborting." >&2
|
echo "Found another container named '$2'. Aborting." >&2
|
||||||
exit 1
|
return 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@@ -1689,7 +1689,14 @@ stop_proxy() {
|
|||||||
stop $PROXY_CONTAINER_NAME "Proxy"
|
stop $PROXY_CONTAINER_NAME "Proxy"
|
||||||
}
|
}
|
||||||
|
|
||||||
launch_plugin() {
|
launch_plugin_if_not_running() {
|
||||||
|
retval=0
|
||||||
|
check_not_running plugin $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE || retval=$?
|
||||||
|
# If an existing plugin is running (we start it with restart=always), return its ID
|
||||||
|
[ $retval = 1 ] && PLUGIN_CONTAINER=$(container_id $PLUGIN_CONTAINER_NAME) && return 0
|
||||||
|
# Any other kind of error code from check_not_running is a failure.
|
||||||
|
[ $retval -gt 0 ] && return $retval
|
||||||
|
|
||||||
PLUGIN_CONTAINER=$(docker run --privileged -d --name=$PLUGIN_CONTAINER_NAME \
|
PLUGIN_CONTAINER=$(docker run --privileged -d --name=$PLUGIN_CONTAINER_NAME \
|
||||||
--restart=always \
|
--restart=always \
|
||||||
--net=host \
|
--net=host \
|
||||||
@@ -1846,11 +1853,11 @@ EOF
|
|||||||
deprecation_warnings "$@"
|
deprecation_warnings "$@"
|
||||||
check_not_running router $CONTAINER_NAME $BASE_IMAGE
|
check_not_running router $CONTAINER_NAME $BASE_IMAGE
|
||||||
check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
|
check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE
|
||||||
check_not_running plugin $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE
|
# Don't check the plugin here, since we start it with `--restart=always`
|
||||||
COMMON_ARGS=$(common_launch_args "$@")
|
COMMON_ARGS=$(common_launch_args "$@")
|
||||||
launch_router "$@"
|
launch_router "$@"
|
||||||
launch_proxy $COMMON_ARGS
|
launch_proxy $COMMON_ARGS
|
||||||
plugin_disabled || launch_plugin $COMMON_ARGS
|
plugin_disabled || launch_plugin_if_not_running $COMMON_ARGS
|
||||||
;;
|
;;
|
||||||
launch-router)
|
launch-router)
|
||||||
deprecation_warnings "$@"
|
deprecation_warnings "$@"
|
||||||
@@ -1873,8 +1880,7 @@ EOF
|
|||||||
echo $PROXY_CONTAINER
|
echo $PROXY_CONTAINER
|
||||||
;;
|
;;
|
||||||
launch-plugin)
|
launch-plugin)
|
||||||
check_not_running plugin $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE
|
launch_plugin_if_not_running "$@"
|
||||||
launch_plugin "$@"
|
|
||||||
echo $PLUGIN_CONTAINER
|
echo $PLUGIN_CONTAINER
|
||||||
;;
|
;;
|
||||||
env|proxy-env)
|
env|proxy-env)
|
||||||
|
|||||||
Reference in new issue
Block a user