Repository navigation
fix(monitor): refresh channel bearers while running - #453
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the airc bash monitor’s multi-channel mode to refresh channel_gists while the monitor is running, allowing newly added channels to start their bearers immediately and removed channels’ bearers to be stopped without restarting the whole monitor/formatter pipeline.
Changes:
- Introduces a
_start_channel_bearerhelper for spawning per-channelbearer_cli recvprocesses. - Adds an in-loop
channel_gistsrefresh to start bearers for newly added channels during steady-state monitoring. - Stops bearers for channels removed from
channel_gistswhile keeping other channels running.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1393
to
+1395
| _current_map=$("$AIRC_PYTHON" -m airc_core.config list_channel_gists \ | ||
| --config "$CONFIG" 2>/dev/null || true) | ||
| if [ -n "$_current_map" ]; then |
| _kept+=("$entry") | ||
| else | ||
| echo "airc: #${ch} removed from channel_gists; stopping its bearer while other channels continue" >&2 | ||
| kill "$pid" 2>/dev/null || true |
Comment on lines
+1392
to
+1419
| local _current_map | ||
| _current_map=$("$AIRC_PYTHON" -m airc_core.config list_channel_gists \ | ||
| --config "$CONFIG" 2>/dev/null || true) | ||
| if [ -n "$_current_map" ]; then | ||
| local _kept=() | ||
| for entry in "${_pids[@]}"; do | ||
| pid="${entry%%:*}" | ||
| ch="${entry#*:}" | ||
| if printf '%s\n' "$_current_map" | awk -F '\t' -v c="$ch" '$1 == c {found=1} END {exit found ? 0 : 1}'; then | ||
| _kept+=("$entry") | ||
| else | ||
| echo "airc: #${ch} removed from channel_gists; stopping its bearer while other channels continue" >&2 | ||
| kill "$pid" 2>/dev/null || true | ||
| fi | ||
| done | ||
| _pids=("${_kept[@]}") | ||
|
|
||
| while IFS=$'\t' read -r ch gid; do | ||
| [ -z "$ch" ] && continue | ||
| local _already=0 | ||
| for entry in "${_pids[@]}"; do | ||
| [ "${entry#*:}" = "$ch" ] && _already=1 && break | ||
| done | ||
| if [ "$_already" = "0" ]; then | ||
| echo "airc: #${ch} added to channel_gists; starting bearer without full monitor restart" >&2 | ||
| _start_channel_bearer "$ch" "$gid" | ||
| fi | ||
| done <<< "$_current_map" |
Comment on lines
+1385
to
+1391
| # Live channel-map refresh. `airc join --room X` can add a | ||
| # channel while the monitor is already healthy; pre-fix the | ||
| # monitor only re-read channel_gists on the next outer restart, | ||
| # so the promised "bearer picks it up within ~30s" was false | ||
| # unless something else died. Start newly-added channels and | ||
| # stop removed channels in-place while the formatter pipe stays | ||
| # alive. |
| @@ -1331,6 +1332,9 @@ _monitor_multi_channel() { | |||
| --state-file "$AIRC_WRITE_DIR/bearer_state.${ch}.json" \ | |||
| 2>>"$AIRC_WRITE_DIR/bearer_recv.${ch}.log" & | |||
| _pids+=("$!:$ch") | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Live testing #452 exposed another common monitor-heal case:
airc join --room Xwhile the monitor is already healthy says the bearer will pick the room up within ~30s, but the monitor only re-read channel_gists at the next outer restart. If no bearer died, the new room never started.Verification
bash -n aircgit diff --check./test/integration.sh inboxQA ask
With a running monitor, run
airc join --room <new-room>and verify a bearer for the new channel appears without bouncing the whole scope.