feat(discord): binding reload without a restart, and a per-user channel allowlist (#1509)
`reload` validates the binding file and sends SIGHUP to the live owner; the running connector re-reads it and swaps guildName, channels, users and limits in place. name, seat, guildId, botUserId, tokenFile, engine and context are fixed for the life of the process; a change there, an invalid file or a channel outside the guild refuses the reload and keeps the old binding. Every attempt is one line in reloads.jsonl. The service unit maps `systemctl --user reload` to the same signal. A user entry may carry `channels`, an allowlist of listed channel ids; absent means every listed channel. Outside the list the message is dropped as channel-not-for-user; threads count as their parent. Suite 41/41, 101 node tests. QUEUE rows 19 and 20 opened. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# `scripts/discord.sh check|run|stop|unlock <binding>`: the Discord connector for
|
||||
# `scripts/discord.sh check|run|stop|unlock|recover|reload <binding>`: the Discord connector for
|
||||
# one seat on one server. See packages/discord/README.md. The binding lives
|
||||
# at <dataRoot>/discord/<binding>.json (0600, never committed); the token
|
||||
# stays in the seat's private secrets directory and is read at runtime only.
|
||||
|
||||
@@ -74,6 +74,9 @@ check "scripts/discord.sh check without a binding exits 4" $?
|
||||
scripts/discord.sh recover >/dev/null 2>&1
|
||||
[ $? -eq 4 ]
|
||||
check "scripts/discord.sh recover without a binding exits 4" $?
|
||||
scripts/discord.sh reload >/dev/null 2>&1
|
||||
[ $? -eq 4 ]
|
||||
check "scripts/discord.sh reload without a binding exits 4" $?
|
||||
|
||||
# --- the service unit: rendered from the template, never touching systemd here ---
|
||||
UNITS="$SANDBOX/units"
|
||||
@@ -87,8 +90,9 @@ scripts/discord-service.sh render >"$SANDBOX/unit.rendered" 2>/dev/null \
|
||||
&& grep -qx 'RestartPreventExitStatus=3' "$SANDBOX/unit.rendered" \
|
||||
&& grep -qx 'Restart=on-failure' "$SANDBOX/unit.rendered" \
|
||||
&& grep -qx 'KillSignal=SIGTERM' "$SANDBOX/unit.rendered" \
|
||||
&& grep -qx 'ExecReload=/bin/kill -HUP $MAINPID' "$SANDBOX/unit.rendered" \
|
||||
&& ! grep -q '@REPO@\|@PATH@' "$SANDBOX/unit.rendered"
|
||||
check "service unit renders with the repository path, a supervised run as the main process, and exit 3 never retried" $?
|
||||
check "service unit renders with the repository path, a supervised run as the main process, exit 3 never retried, and reload as SIGHUP" $?
|
||||
scripts/discord-service.sh install --dir "$UNITS" --no-reload >"$SANDBOX/install.1" 2>&1 \
|
||||
&& [ -f "$UNITS/[email protected]" ] \
|
||||
&& grep -q '^written:' "$SANDBOX/install.1" \
|
||||
|
||||
Reference in New Issue
Block a user