bento: status now waits for changes in chroot dir in an infinite loop

This commit is contained in:
Solene Rapenne 2022-10-06 22:29:41 +02:00
parent 2392b7720f
commit fcb949881a
4 changed files with 19 additions and 7 deletions

12
bento
View File

@ -5,7 +5,7 @@ TIMEOUT=20
# FUNCTION LIBRARIES
usage() {
cat <<EOF
usage: bento init | deploy | diff | build [dry-run|test|switch] | status [delay] | flake-update [input]
usage: bento init | deploy | diff | build [dry-run|test|switch] | status | flake-update [input]
bento init
: create the layout for bento in the current directory
@ -19,8 +19,10 @@ bento diff
bento build [dry-run|test|switch]
: build configurations, can activate (test or switch) a build locally
bento status [delay]
bento status
: display information for remote hosts
: if the script isn't run in an interactive terminal, exit after display
: in an interactive terminal, display status and poll for changes to display again
bento flake-update [input]
: recursively update flakes lock files
@ -768,12 +770,14 @@ then
. ./config.sh
cd hosts || exit 5
if [ -n "$2" ]
# if stdout is interactive
# wait for changes and loop
if [ -t 1 ]
then
while true
do
display_status
sleep "$2"
inotifywait -q -e 'modify,create' "${CHROOT_DIR}/states.txt" "${CHROOT_DIR}"/*/logs/ >/dev/null 2>/dev/null
done
else
display_status

View File

@ -78,7 +78,9 @@ If you don't want to wait for the timer, you can ssh into the machine to run `sy
As each host is sending a log upon rebuild to tell if it failed or succeeded, the files are used to check what happened since the sftp file `last_time_changed` was created.
Using `bento status` you can track the current state of each hosts (time since last update, current NixOS version, status report)
Using `bento status` you can track the current state of each hosts (time since last update, current NixOS version, status report).
Bento will display the current state of the fleet, and wait for a change in the chroot directory to display the status again.
[![asciicast](https://asciinema.org/a/520504.svg)](https://asciinema.org/a/520504)

View File

@ -13,8 +13,10 @@
- dry-build or build configurations. Using `test` or `switch`, can be used to apply a configuration locally. Default is `build`.
- when using `TARGET_IP`, the command is run on a remote server
- `bento status [delay]`
- display information for remote hosts, if `delay` is set, loop infinitely to display the status every `delay` seconds. Default delay is `0` and doesn't loop.
- `bento status`
- display information for remote hosts
- if the command is run in interactive mode, `bento` will run in an inifite loop the status display and wait for a change in the chroot directory
- if the command isn't run in interactive mode, the status is only displayed once and `bento` exits
- `bento flake-update [input]`
- recursively update flakes lock files

View File

@ -12,6 +12,10 @@
name = "bento";
src = self;
patchPhase = ''
substituteInPlace bento --replace 'inotifywait' "${pkgs.inotify-tools}/bin/inotifywait";
'';
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share