fix: Add Dendrite to docker-compose stack (#619)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
df640af7c1
commit
b86edd7e5d
6 changed files with 195 additions and 9 deletions
12
lib/env.sh
12
lib/env.sh
|
|
@ -67,6 +67,18 @@ export WOODPECKER_REPO_ID="${WOODPECKER_REPO_ID:-}"
|
|||
export WOODPECKER_SERVER="${WOODPECKER_SERVER:-http://localhost:8000}"
|
||||
export CLAUDE_TIMEOUT="${CLAUDE_TIMEOUT:-7200}"
|
||||
|
||||
# Matrix homeserver: inside compose Dendrite is at http://dendrite:8008,
|
||||
# on bare metal it defaults to http://localhost:8008.
|
||||
if [ -z "${MATRIX_HOMESERVER:-}" ]; then
|
||||
if [ "${DISINTO_CONTAINER:-}" = "1" ]; then
|
||||
export MATRIX_HOMESERVER="http://dendrite:8008"
|
||||
else
|
||||
export MATRIX_HOMESERVER="http://localhost:8008"
|
||||
fi
|
||||
else
|
||||
export MATRIX_HOMESERVER
|
||||
fi
|
||||
|
||||
# Shared log helper
|
||||
log() {
|
||||
printf '[%s] %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC')" "$*"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# Legacy systemd unit for bare-metal deployments (disinto init --bare).
|
||||
# In compose mode, the matrix listener runs inside the agent container
|
||||
# as a background process — see docker/agents/entrypoint.sh.
|
||||
[Unit]
|
||||
Description=Disinto Matrix Listener
|
||||
After=network.target dendrite.service
|
||||
|
|
|
|||
|
|
@ -20,14 +20,19 @@ set -euo pipefail
|
|||
# Load shared environment
|
||||
source "$(dirname "$0")/../lib/env.sh"
|
||||
|
||||
# Pidfile guard — prevent duplicate listener processes
|
||||
# Pidfile guard — prevent duplicate listener processes.
|
||||
# Inside a container the PID file from a previous run is stale (container
|
||||
# restart resets the PID namespace), so we only honour it when the recorded
|
||||
# PID is still alive.
|
||||
PIDFILE="/tmp/matrix-listener.pid"
|
||||
if [ -f "$PIDFILE" ]; then
|
||||
OLD_PID=$(cat "$PIDFILE")
|
||||
if kill -0 "$OLD_PID" 2>/dev/null; then
|
||||
OLD_PID=$(cat "$PIDFILE" 2>/dev/null || true)
|
||||
if [ -n "$OLD_PID" ] && kill -0 "$OLD_PID" 2>/dev/null; then
|
||||
echo "Listener already running (PID $OLD_PID)" >&2
|
||||
exit 0
|
||||
fi
|
||||
# Stale pidfile (previous container run or crashed process) — remove it
|
||||
rm -f "$PIDFILE"
|
||||
fi
|
||||
echo $$ > "$PIDFILE"
|
||||
trap 'rm -f "$PIDFILE"' EXIT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue