Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.github
README.md
LICENSE
lab
*.md
.vscode
.gitignore
.DS_Store
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
commit-message:
prefix: "chore"
include: "scope"
ignore:
- dependency-name: "debian"
update-types: ["version-update:semver-major"]

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
commit-message:
prefix: "chore"
include: "scope"
17 changes: 17 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Auto-merge Dependabot PRs

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
check_suite:
types: [completed]

permissions:
contents: write
pull-requests: write
checks: read

jobs:
auto-merge:
uses: actionsforge/actions/.github/workflows/dependabot-auto-merge.yml@main
secrets: inherit
17 changes: 17 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build and Release

on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:

jobs:
build:
permissions:
contents: write
packages: write
uses: actionsforge/actions/.github/workflows/docker-image-release.yml@main
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CI

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
uses: actionsforge/actions/.github/workflows/docker-image-validate.yml@main
with:
image-tag: "ringserver-feeder:test"
scan-enabled: false
14 changes: 14 additions & 0 deletions .github/workflows/commitmsg-conform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Commit Message Conformance

on:
pull_request: {}

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
commitmsg-conform:
uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Markdown Lint

on:
pull_request: {}

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
markdown-lint:
uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Debian bookworm + EarthScope libs. Pin upstream tags via build args.

ARG BASE=debian:bookworm-slim
ARG SLINK2DALI_VERSION=v0.8
ARG LIBDALI_VERSION=develop

FROM ${BASE} AS buildenv
ARG SLINK2DALI_VERSION
ARG LIBDALI_VERSION
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
clang \
git \
make \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /build
RUN git clone --depth 1 --branch "${SLINK2DALI_VERSION}" \
https://github.com/EarthScope/slink2dali.git upstream \
&& rm -rf upstream/libdali \
&& git clone --depth 1 --branch "${LIBDALI_VERSION}" \
https://github.com/EarthScope/libdali.git upstream/libdali

COPY src/ringserver-feeder.c upstream/src/
COPY src/Makefile upstream/src/

RUN cd upstream \
&& make CC=clang \
&& make -C src CC=clang

FROM ${BASE}
ARG DEBIAN_FRONTEND=noninteractive
ARG UID=10000
ARG GID=10000
ARG USERNAME=containeruser

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
netbase \
procps \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

COPY --from=buildenv /build/upstream/ringserver-feeder /ringserver-feeder

RUN groupadd --gid "${GID}" "${USERNAME}" \
&& adduser --uid "${UID}" --gid "${GID}" "${USERNAME}" \
&& mkdir -p /data \
&& chown -R "${UID}:${GID}" /data

WORKDIR /data
USER ${USERNAME}

ENV FEEDER_STATE_FILE=/data/seedlink.state
ENV FEEDER_PKTID_FILE=/data/pktid.state
ENV FEEDER_LOCK_FILE=/data/feeder.lock

ENTRYPOINT ["/ringserver-feeder"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Platform Fuzz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# ringserver-feeder
SeedLink to DataLink feeder with shared packet IDs

![CI](https://github.com/platformfuzz/ringserver-feeder/actions/workflows/ci.yml/badge.svg)
![Build and Release](https://github.com/platformfuzz/ringserver-feeder/actions/workflows/build-and-release.yml/badge.svg)

SeedLink client that writes the same DataLink packet ID to every ringserver replica.

Pulls upstream SeedLink and fans each miniSEED record out with DataLink 1.1
`WRITE` flag `I` so NLB clients can resume on any replica. Derived from EarthScope
slink2dali; uses libdali `dl_write_id()`.

**Package:** [ghcr.io/platformfuzz/ringserver-feeder](https://github.com/platformfuzz/ringserver-feeder/pkgs/container/ringserver-feeder)

## Run

```bash
docker pull ghcr.io/platformfuzz/ringserver-feeder:latest
docker run --rm \
-e FEEDER_SEEDLINK_HOST=upstream:18000 \
-e FEEDER_DATALINK_HOSTS=rs0:16000,rs1:16000 \
-v feeder-data:/data \
ghcr.io/platformfuzz/ringserver-feeder:latest
```

| Variable | Purpose |
| --- | --- |
| `FEEDER_SEEDLINK_HOST` | Upstream SeedLink `host:port` |
| `FEEDER_DATALINK_HOSTS` | Comma-separated DataLink targets |
| `FEEDER_STATE_FILE` | SeedLink resume state (default `/data/seedlink.state`) |
| `FEEDER_PKTID_FILE` | Last written packet ID (default `/data/pktid.state`) |
| `FEEDER_LOCK_FILE` | Single-writer lock (default `/data/feeder.lock`) |

slink2dali-style flags (`-s`, `-S`, `-l`, `-x`, `-nd`, `-nt`, `-k`) also work.

## Lab

```bash
cd lab
docker compose up --build -d
./prove.sh
docker compose down
```

Upstream ringserver scans `lab/miniseed/`. The feeder writes to `rs0` and `rs1`.
`prove.sh` checks both replicas expose the same latest DataLink packet ID.

## Build

```bash
docker build -t ringserver-feeder:test .
```
3 changes: 3 additions & 0 deletions lab/config/replica.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RingDirectory /data/ring
RingSize 32m
WriteIP 0.0.0.0/0
3 changes: 3 additions & 0 deletions lab/config/upstream.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RingDirectory /data/ring
RingSize 32m
MSeedScan /seed Match=.* Reject= InitCurrentState=y
45 changes: 45 additions & 0 deletions lab/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
services:
upstream:
image: earthscope/ringserver:4.5.6
volumes:
- ./miniseed:/seed:ro
- ./config/upstream.conf:/config/ringserver.conf:ro
- upstream-data:/data
environment:
RS_CONFIG_FILE: /config/ringserver.conf

rs0:
image: earthscope/ringserver:4.5.6
volumes:
- ./config/replica.conf:/config/ringserver.conf:ro
- rs0-data:/data
environment:
RS_CONFIG_FILE: /config/ringserver.conf

rs1:
image: earthscope/ringserver:4.5.6
volumes:
- ./config/replica.conf:/config/ringserver.conf:ro
- rs1-data:/data
environment:
RS_CONFIG_FILE: /config/ringserver.conf

feeder:
build: ..
restart: on-failure
depends_on:
- upstream
- rs0
- rs1
volumes:
- feeder-data:/data
environment:
FEEDER_SEEDLINK_HOST: upstream:18000
FEEDER_DATALINK_HOSTS: rs0:16000,rs1:16000
FEEDER_VERBOSE: "1"

volumes:
upstream-data:
rs0-data:
rs1-data:
feeder-data:
Binary file added lab/miniseed/test.mseed
Binary file not shown.
50 changes: 50 additions & 0 deletions lab/prove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")"
NETWORK="$(docker compose ps -q feeder | xargs docker inspect -f '{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}' | head -1)"

read_pktid() {
local host="$1"
docker run --rm --network "$NETWORK" python:3.12-slim python3 - <<PY
import socket

host = "${host}"
port = 16000
s = socket.create_connection((host, port), timeout=5)
s.sendall(b"ID ringserver-feeder-probe:probe:1:linux\\r")
buf = b""
while b"\\r" not in buf:
chunk = s.recv(4096)
if not chunk:
break
buf += chunk
s.sendall(b"POSITION SET LATEST\\r")
buf = b""
while b"\\r" not in buf:
chunk = s.recv(4096)
if not chunk:
break
buf += chunk
line = buf.decode("ascii", errors="replace").split("\\r")[0]
parts = line.split()
if len(parts) >= 2 and parts[0] in ("OK", "ERROR"):
print(parts[1])
else:
print("0")
PY
}

id0="$(read_pktid rs0)"
id1="$(read_pktid rs1)"

echo "rs0 latest pktid: $id0"
echo "rs1 latest pktid: $id1"

if [[ -n "$id0" && -n "$id1" && "$id0" == "$id1" && "$id0" != "0" ]]; then
echo "PASS: replicas share packet IDs"
exit 0
fi

echo "FAIL: packet IDs differ or ring is empty"
exit 1
18 changes: 18 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Build ringserver-feeder against EarthScope libs cloned in the Docker build stage.

CFLAGS ?= -O3
CFLAGS += -I../libslink -I../libdali -I../libmseed

LDFLAGS = -L../libslink -L../libdali -L../libmseed
LDLIBS = -lslink -ldali -lmseed

BIN = ../ringserver-feeder
OBJS = ringserver-feeder.o

all: $(BIN)

$(BIN): $(OBJS)
$(CC) $(CFLAGS) -o $(BIN) $(OBJS) $(LDFLAGS) $(LDLIBS)

clean:
rm -f $(OBJS) $(BIN)
Loading