diff options
author | Alejandro Colomar <alx@nginx.com> | 2023-06-06 14:55:14 +0200 |
---|---|---|
committer | Alejandro Colomar <alx@nginx.com> | 2023-06-27 17:45:49 +0200 |
commit | 2f46870a3f799ebb3a23e23b02a9dbee3a33ff46 (patch) | |
tree | 67ab8465d7e9eebcd857104a4d46b1efc431aa2c /tools | |
parent | e165801732defc5726a3c727b83e31bc3369026f (diff) | |
download | unit-2f46870a3f799ebb3a23e23b02a9dbee3a33ff46.tar.gz unit-2f46870a3f799ebb3a23e23b02a9dbee3a33ff46.tar.bz2 |
Tools: setup-unit: added restart command.
It restarts all running unitd instances. This is useful when
recompiling unitd often, so that the latest build is running, without
having to manually kill unitd instances and re-run with the same exact
command line every time.
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/setup-unit | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/setup-unit b/tools/setup-unit index c95d7b35..5baa5467 100755 --- a/tools/setup-unit +++ b/tools/setup-unit @@ -84,6 +84,7 @@ SYNOPSIS ├── os-probe [-h] ├── ps [-h] [-t TYPE] ├── repo-config [-hn] [PKG-MANAGER OS-NAME OS-VERSION] + ├── restart [-h] ├── sock [-h] SUBCOMMAND [ARGS] │ ├── filter [-chs] │ └── find [-h] @@ -1219,6 +1220,52 @@ __EOF__"; } +help_unit_restart() +{ + cat <<__EOF__ ; +SYNOPSIS + $0 restart [-h] + +DESCRIPTION + Restart all running unitd(8) instances. + +OPTIONS + -h, --help + Print this help. + +__EOF__ +} + + +unit_restart() +{ + while test $# -ge 1; do + case "$1" in + -h | --help) + help_unit_restart; + exit 0; + ;; + -*) + err "restart: $1: Unknown option."; + ;; + *) + err "restart: $1: Unknown argument."; + ;; + esac; + shift; + done; + + local cmds="$(unit_cmd)"; + + pkill -e unitd; + + printf '%s\n' "$cmds" \ + | while read -r cmd; do + eval $cmd; + done; +} + + help_unit_sock() { cat <<__EOF__ ; @@ -1478,6 +1525,10 @@ repo-config) shift; unit_repo_config $@; ;; +restart) + shift; + unit_restart $@; + ;; sock) shift; unit_sock $@; |