Skip to content

Commit dda4e48

Browse files
committed
Restart monitor after signal watchlist refresh
1 parent 61cc51b commit dda4e48

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

scripts/background_manager.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ case "$COMMAND" in
269269
fi
270270

271271
if [[ "$ENABLE_EXTERNAL_SIGNALS" == "1" && "$now" -ge "$next_external" ]]; then
272+
before_sig="$(file_sig "$WATCHLIST")"
272273
run_logged external-signals scripts/refresh_external_signals.sh
274+
after_sig="$(file_sig "$WATCHLIST")"
275+
if [[ "$before_sig" != "$after_sig" ]]; then
276+
restart_monitor
277+
fi
273278
next_external=$((now + EXTERNAL_SIGNALS_INTERVAL))
274279
fi
275280

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import unittest
2+
from pathlib import Path
3+
4+
5+
class BackgroundManagerScriptTests(unittest.TestCase):
6+
def test_external_signal_refresh_restarts_monitor_when_watchlist_changes(self):
7+
root = Path(__file__).resolve().parents[1]
8+
text = (root / "scripts" / "background_manager.sh").read_text()
9+
block = text.split('if [[ "$ENABLE_EXTERNAL_SIGNALS" == "1"')[1].split(
10+
'if [[ "$ENABLE_DISCOVERY_REFRESH" == "1"'
11+
)[0]
12+
13+
self.assertIn('before_sig="$(file_sig "$WATCHLIST")"', block)
14+
self.assertIn('after_sig="$(file_sig "$WATCHLIST")"', block)
15+
self.assertIn('if [[ "$before_sig" != "$after_sig" ]]', block)
16+
self.assertIn("restart_monitor", block)
17+
18+
19+
if __name__ == "__main__":
20+
unittest.main()

0 commit comments

Comments
 (0)