Enable working expose/unexpose commands
`expose` and `unexpose` commands are now fully functionnal using the ambassador pattern. This has the advantage to be a 100% docker solution and to not have to restart the service container. Multiple ports are exposed when service specify them. `start` and `stop` commands have been made more robust. When calling `start` or `stop` on an already started (or stopped) service, an error will be printed out instead of issuing failing commands. Exposed services will still be exposed after a `restart`. Also the service containers (and ambassador containers) will start automatically when docker boot up.
This commit is contained in:
21
commands
21
commands
@@ -35,7 +35,8 @@ case "$1" in
|
||||
touch "$LINKS_FILE"
|
||||
|
||||
dokku_log_info1 "Starting container"
|
||||
ID=$(docker run --name "dokku.redis.$SERVICE" -v "$SERVICE_ROOT/data:/data" -v "$SERVICE_ROOT/config:/usr/local/etc/redis" -d "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
|
||||
SERVICE_NAME=$(get_service_name "$SERVICE")
|
||||
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_ROOT/data:/data" -v "$SERVICE_ROOT/config:/usr/local/etc/redis" -d --restart always "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION")
|
||||
echo "$ID" > "$SERVICE_ROOT/ID"
|
||||
|
||||
dokku_log_verbose_quiet "Waiting for container to be ready"
|
||||
@@ -73,10 +74,7 @@ case "$1" in
|
||||
dokku_log_verbose_quiet "Deleting container data"
|
||||
docker exec -it "$ID" chmod -R 777 /data
|
||||
|
||||
dokku_log_verbose_quiet "Stopping container"
|
||||
docker stop "$ID" > /dev/null
|
||||
docker kill "$ID" > /dev/null
|
||||
sleep 1
|
||||
service_stop "$SERVICE"
|
||||
|
||||
dokku_log_verbose_quiet "Removing container"
|
||||
docker rm -v "$ID" > /dev/null
|
||||
@@ -144,11 +142,8 @@ case "$1" in
|
||||
$PLUGIN_COMMAND_PREFIX:restart)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||
verify_service_name "$2"
|
||||
SERVICE="$2"; SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||
|
||||
ID=$(cat "$SERVICE_ROOT/ID")
|
||||
|
||||
docker restart --time=10 "$ID"
|
||||
service_stop "$2"
|
||||
service_start "$2"
|
||||
dokku_log_info1 "Please call dokku ps:restart on all linked apps"
|
||||
;;
|
||||
|
||||
@@ -183,7 +178,7 @@ case "$1" in
|
||||
$PLUGIN_COMMAND_PREFIX:expose)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||
verify_service_name "$2"
|
||||
service_port_expose "$2"
|
||||
service_port_expose "$2" "${@:3}"
|
||||
;;
|
||||
|
||||
$PLUGIN_COMMAND_PREFIX:unexpose)
|
||||
@@ -207,8 +202,8 @@ case "$1" in
|
||||
$PLUGIN_COMMAND_PREFIX:info <name>, Print the connection information
|
||||
$PLUGIN_COMMAND_PREFIX:list, List all $PLUGIN_SERVICE services
|
||||
$PLUGIN_COMMAND_PREFIX:clone <name> <new-name>, NOT IMPLEMENTED
|
||||
$PLUGIN_COMMAND_PREFIX:expose <name> <port>, NOT IMPLEMENTED
|
||||
$PLUGIN_COMMAND_PREFIX:unexpose <name> <port>, NOT IMPLEMENTED
|
||||
$PLUGIN_COMMAND_PREFIX:expose <name> [port], Expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)
|
||||
$PLUGIN_COMMAND_PREFIX:unexpose <name>, Unexpose a previously exposed $PLUGIN_SERVICE service
|
||||
EOF
|
||||
;;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user