implement recreate, reload and status, and stop advertising -H
The usage listed recreate but the dispatcher did not know it: myos recreate exited 2 saying the command was unknown. status was missing too, and -H was parsed into a variable nothing ever reads, so it was accepted and ignored. It now refuses rather than pretending.
This commit is contained in:
@@ -44,7 +44,6 @@ myos_is_command() {
|
|||||||
MYOS_REFS_RAW=
|
MYOS_REFS_RAW=
|
||||||
MYOS_VARS=
|
MYOS_VARS=
|
||||||
MYOS_ARGS=
|
MYOS_ARGS=
|
||||||
MYOS_HOSTS=
|
|
||||||
MYOS_COLOR=${MYOS_COLOR:-auto}
|
MYOS_COLOR=${MYOS_COLOR:-auto}
|
||||||
VERBOSE=${VERBOSE:-}
|
VERBOSE=${VERBOSE:-}
|
||||||
DEBUG=${DEBUG:-}
|
DEBUG=${DEBUG:-}
|
||||||
@@ -57,7 +56,6 @@ Usage: myos [options] <command> [stack...] [VAR=value...] [-- args...]
|
|||||||
Options:
|
Options:
|
||||||
-C DIR work in DIR instead of the current directory
|
-C DIR work in DIR instead of the current directory
|
||||||
-e ENV environment (default: local, or ENV from the config)
|
-e ENV environment (default: local, or ENV from the config)
|
||||||
-H HOSTS run on remote hosts instead (comma separated, or "all")
|
|
||||||
-n, --dry-run print the commands instead of running them
|
-n, --dry-run print the commands instead of running them
|
||||||
--color WHEN always, never or auto (default: colour when on a terminal)
|
--color WHEN always, never or auto (default: colour when on a terminal)
|
||||||
-v, --verbose show what myos does
|
-v, --verbose show what myos does
|
||||||
@@ -66,7 +64,7 @@ Options:
|
|||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
up down start stop restart recreate manage the containers of a stack
|
up down start stop restart recreate manage the containers of a stack
|
||||||
ps logs config exec run inspect and enter them
|
ps status logs config exec run inspect and enter them
|
||||||
ls [--groups] list the stacks myos can see
|
ls [--groups] list the stacks myos can see
|
||||||
env [VAR...] show resolved variables
|
env [VAR...] show resolved variables
|
||||||
export every setting of the stacks, as KEY=value
|
export every setting of the stacks, as KEY=value
|
||||||
@@ -86,7 +84,9 @@ while [ $# -gt 0 ]; do
|
|||||||
case $1 in
|
case $1 in
|
||||||
-C) WORKDIR=$2; shift 2 ;;
|
-C) WORKDIR=$2; shift 2 ;;
|
||||||
-e) ENV=$2; shift 2 ;;
|
-e) ENV=$2; shift 2 ;;
|
||||||
-H) MYOS_HOSTS=$2; shift 2 ;;
|
# running on remote hosts is not implemented yet; the flag is refused
|
||||||
|
# rather than silently ignored
|
||||||
|
-H) myos_die "$MYOS_E_USAGE" "-H is not implemented yet: run myos on the host itself" ;;
|
||||||
-n|--dry-run) DRYRUN=true; shift ;;
|
-n|--dry-run) DRYRUN=true; shift ;;
|
||||||
--color) MYOS_COLOR=$2; shift 2 ;;
|
--color) MYOS_COLOR=$2; shift 2 ;;
|
||||||
--color=*) MYOS_COLOR=${1#--color=}; shift ;;
|
--color=*) MYOS_COLOR=${1#--color=}; shift ;;
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#shellcheck shell=sh
|
||||||
|
# myos recreate remove the containers and create them again
|
||||||
|
# myos reload the same, under the name the make engine used
|
||||||
|
myos_cmd_recreate() {
|
||||||
|
# shellcheck source=lib/cmd/_compose.sh
|
||||||
|
. "$MYOS_ROOT/lib/cmd/_compose.sh"
|
||||||
|
MYOS_ARGS="--force-recreate ${MYOS_ARGS:-}"
|
||||||
|
myos_cmd_compose up
|
||||||
|
}
|
||||||
|
myos_cmd_reload() { myos_cmd_recreate; }
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#shellcheck shell=sh
|
||||||
|
# myos reload: see lib/cmd/recreate.sh
|
||||||
|
# shellcheck source=lib/cmd/recreate.sh
|
||||||
|
. "$MYOS_ROOT/lib/cmd/recreate.sh"
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#shellcheck shell=sh
|
||||||
|
# myos status what is running, under the name the make engine used for ps
|
||||||
|
myos_cmd_status() {
|
||||||
|
# shellcheck source=lib/cmd/_compose.sh
|
||||||
|
. "$MYOS_ROOT/lib/cmd/_compose.sh"
|
||||||
|
myos_cmd_compose ps
|
||||||
|
}
|
||||||
+4
-6
@@ -39,13 +39,11 @@ endef
|
|||||||
# The settings of the stacks, read once and evaluated here.
|
# The settings of the stacks, read once and evaluated here.
|
||||||
# A stack keeps its settings in hooks that only myos reads; asking for them one
|
# A stack keeps its settings in hooks that only myos reads; asking for them one
|
||||||
# at a time costs a process per variable, so they come in a single call.
|
# at a time costs a process per variable, so they come in a single call.
|
||||||
|
## Written while this file is read, not as a target: a target would collide
|
||||||
|
## with the catch-all rule at the bottom, which hands anything else to myos.
|
||||||
MYOS_SETTINGS ?= .myos.settings.mk
|
MYOS_SETTINGS ?= .myos.settings.mk
|
||||||
$(MYOS_SETTINGS):
|
MYOS_SETTINGS_FILE := $(shell $(MYOS_BIN) --color=never $(MYOS_ARGS) export --make > $(MYOS_SETTINGS) 2>/dev/null && echo $(MYOS_SETTINGS))
|
||||||
@$(MYOS_BIN) --color=never $(MYOS_ARGS) export --make > $@ 2>/dev/null || : > $@
|
-include $(MYOS_SETTINGS_FILE)
|
||||||
-include $(MYOS_SETTINGS)
|
|
||||||
## regenerated on every run, and the catch-all below must not hand this file
|
|
||||||
## to myos as if it were a command
|
|
||||||
.PHONY: $(MYOS_SETTINGS)
|
|
||||||
|
|
||||||
# function myos-var: the value myos resolves for one variable, when a single
|
# function myos-var: the value myos resolves for one variable, when a single
|
||||||
# lookup is cheaper than the whole set
|
# lookup is cheaper than the whole set
|
||||||
|
|||||||
@@ -87,3 +87,5 @@ chain-print-two | host-project | print-COMPOSE_PROJECT_NAME pri
|
|||||||
mk-ssh-no-hosts | app-nogit | ssh
|
mk-ssh-no-hosts | app-nogit | ssh
|
||||||
mk-ssh-with-hosts | app-nogit | ssh SSH_HOSTS=example.test ARGS=id
|
mk-ssh-with-hosts | app-nogit | ssh SSH_HOSTS=example.test ARGS=id
|
||||||
bridge-export | host-project | export STACK=host/consul
|
bridge-export | host-project | export STACK=host/consul
|
||||||
|
cmd-recreate | host-project | recreate host/consul
|
||||||
|
cmd-status | host-project | status host/consul
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
docker network create tester-local
|
||||||
|
docker network create testhost
|
||||||
|
docker compose -f @WD@/stack/host/consul.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host up -d --force-recreate
|
||||||
|
[exit 0]
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
docker compose -f @WD@/stack/host/consul.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host ps
|
||||||
|
[exit 0]
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
@MYOS@/share/make/shim.mk:66: warning: overriding commands for target `.myos.settings.mk'
|
|
||||||
@MYOS@/share/make/shim.mk:44: warning: ignoring old commands for target `.myos.settings.mk'
|
|
||||||
docker compose -f @WD@/stack/host/consul.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host config
|
|
||||||
[exit 0]
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
@MYOS@/share/make/shim.mk:66: warning: overriding commands for target `.myos.settings.mk'
|
|
||||||
@MYOS@/share/make/shim.mk:44: warning: ignoring old commands for target `.myos.settings.mk'
|
|
||||||
would renew the certificates of host/consul host/fabio
|
|
||||||
[exit 0]
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
@MYOS@/share/make/shim.mk:66: warning: overriding commands for target `.myos.settings.mk'
|
|
||||||
@MYOS@/share/make/shim.mk:44: warning: ignoring old commands for target `.myos.settings.mk'
|
|
||||||
docker network create tester-local
|
|
||||||
docker network create testhost
|
|
||||||
docker compose -f @WD@/stack/host/consul.yml -f @WD@/stack/host/fabio.yml -f @MYOS@/share/compose/networks.yml -p testhost --project-directory @WD@/stack/host up -d
|
|
||||||
[exit 0]
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
make -o docker-stack-recreate MAKE_OLDFILE=docker-stack-recreate ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-recreate STACK=myos APP_NAME=myos
|
||||||
|
docker --log-level=error compose --ansi=auto -f @MYOS@/share/compose/networks.yml -p tester-myos-local rm -fs
|
||||||
|
sh -c docker network create tester-local >/dev/null 2>&1
|
||||||
|
sh -c docker network create testhost >/dev/null 2>&1
|
||||||
|
docker --log-level=error compose --ansi=auto -f @MYOS@/share/compose/networks.yml -p tester-myos-local up -d
|
||||||
|
WARNING: myos[0] host/consul-rule-exists: target host/consul unavailable in app myos
|
||||||
|
[exit 0]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
make -o docker-stack-ps MAKE_OLDFILE=docker-stack-ps ENV=local DOCKER_COMPOSE=docker --log-level=error compose docker-compose-ps STACK=myos APP_NAME=myos
|
||||||
|
docker --log-level=error compose --ansi=auto -f @MYOS@/share/compose/networks.yml -p tester-myos-local ps
|
||||||
|
WARNING: myos[0] host/consul-rule-exists: target host/consul unavailable in app myos
|
||||||
|
[exit 0]
|
||||||
Reference in New Issue
Block a user