Files
stack/packages/discord/systemd/[email protected]
T
jason.woltjeandClaude Fable 5.1 caaef941e6 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]>
2026-09-13 18:59:31 -05:00

40 lines
1.6 KiB
Plaintext

# Mosaic Discord connector, one instance per binding: mosaic-discord@<binding>.
# Rendered by scripts/discord-service.sh from packages/discord/systemd/;
# @REPO@ and @PATH@ are filled in at install time. Edit the template and
# reinstall; do not edit the installed copy.
[Unit]
Description=Mosaic Discord connector (%i)
Documentation=file://@REPO@/packages/discord/README.md
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=600
StartLimitBurst=5
[Service]
Type=simple
WorkingDirectory=@REPO@
Environment=PATH=@PATH@
# A supervised run first clears a lock left by a crash or a reboot, and
# refuses with exit 3 while STOP is present or the binding is held. Exit 3
# is never retried: the brake belongs to the operator. This happens inside
# the main process on purpose: systemd honours RestartPreventExitStatus only
# for the main process, so a refusing ExecStartPre would loop.
ExecStart=@REPO@/scripts/discord.sh run %i --supervised
# `systemctl --user reload` re-reads the binding in place (channels, users,
# limits); the connector refuses and keeps the old binding when the file is
# invalid or a fixed key changed. See reloads.jsonl under the journal.
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=15
RestartPreventExitStatus=3
# `systemctl --user stop` sends SIGTERM; the connector finishes the turn in
# flight, then exits 0. The stop timeout covers the largest turn timeout a
# binding may set (3600 s) plus margin; a normal stop takes seconds.
KillSignal=SIGTERM
KillMode=mixed
TimeoutStopSec=3700
NoNewPrivileges=yes
[Install]
WantedBy=default.target