mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
Adds synapse-sync (protocol types, Remote transport and read API, SyncClient with background loop, SSE realtime, resumable blobs) and synapse-server (multi-graph, bearer auth, blob streaming, read API, authenticated update endpoint), with e2e tests, docs/sync.md, docs/server.md, systemd unit and update script. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 lines
1.4 KiB
Bash
Executable File
37 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Idempotent update of a Synapse server install: pull, build, install the binary atomically.
|
|
# Run as the service user (by hand or via POST /admin/update). Exit codes:
|
|
# 0 updated; the caller (the server) exits so systemd restarts the new binary
|
|
# 10 already up to date, nothing to restart
|
|
# other: failed; the running binary is left untouched
|
|
set -euo pipefail
|
|
|
|
REPO_DIR="${SYNAPSE_REPO_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
|
BIN_DIR="${SYNAPSE_BIN_DIR:-/opt/synapse/bin}"
|
|
BRANCH="${SYNAPSE_UPDATE_BRANCH:-main}"
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
|
|
log() { printf '%s %s\n' "$(date -u +%FT%TZ)" "$*"; }
|
|
trap 'log "update FAILED (line $LINENO)"' ERR
|
|
|
|
cd "$REPO_DIR"
|
|
log "fetching $BRANCH"
|
|
git fetch --quiet origin "$BRANCH"
|
|
local_rev=$(git rev-parse HEAD)
|
|
remote_rev=$(git rev-parse "origin/$BRANCH")
|
|
if [ "$local_rev" = "$remote_rev" ] && [ -x "$BIN_DIR/synapse-server" ]; then
|
|
log "already up to date ($local_rev)"
|
|
exit 10
|
|
fi
|
|
|
|
log "updating $local_rev -> $remote_rev"
|
|
git merge --ff-only "origin/$BRANCH"
|
|
log "building (release)"
|
|
cargo build --release --locked -p synapse-server
|
|
|
|
# Schema migrations run in synapse-core when each graph is opened; nothing to do here.
|
|
mkdir -p "$BIN_DIR"
|
|
install -m 0755 target/release/synapse-server "$BIN_DIR/synapse-server.new"
|
|
mv -f "$BIN_DIR/synapse-server.new" "$BIN_DIR/synapse-server" # atomic replace
|
|
log "installed $remote_rev"
|