commit 2341827d7928eb70e68c897f851d8c8b8e8f40f7
parent 42f34eef8d5d7026bfa143f217d2c0924e8d5c30
Author: Louis Burda <contact@sinitax.com>
Date: Thu, 24 Apr 2025 15:48:57 +0200
Fix config monitoring and cleanup
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/git-syncd b/git-syncd
@@ -55,8 +55,9 @@ log_prefix() {
git_syncd_watchers=()
kill_watchers() {
for pid in "${git_syncd_watchers}"; do
- kill -9 "$pid"
- timeout 10 wait "$pid" || notify-send "Failed to kill git-syncd watcher"
+ kill -9 "$pid" &>/dev/null
+ waitpid -t 10 "$pid" &>/dev/null
+ kill -0 "$pid" &>/dev/null && notify-send "Failed to kill git-syncd watcher"
done
git_syncd_watchers=()
}
@@ -76,12 +77,14 @@ load_config() {
}
load_config
+trap kill_watchers EXIT
start_watchers
while true; do
- file=$(inotifywait --format "%w%f" -e modify,delete,create "$GIT_SYNCD_CONFIG_DIR" 2>/dev/null)
+ file=$(inotifywait --format "%w%f" -e modify,delete "$GIT_SYNCD_CONFIG")
if [ ! -z "$file" ]; then
mod_path="$(realpath "$file" 2>/dev/null)"
config_path="$(realpath "$GIT_SYNCD_CONFIG" 2>/dev/null)"
+ echo "config $mod_path $config_path"
if [ "$mod_path" = "$config_path" ]; then
kill_watchers
load_config