Files
SocialPub/tools/pasture/peers/shared.sh
T
thepraandClaude Opus 5.5 5f150b7a59 Pasture: Smithereen 1.0.3, and failed server descriptions retried
Smithereen joins the pasture (tools/pasture/peers/smithereen.sh): its image on the shared MySQL, with imgproxy and a
file server behind Caddy, a JDK trust store with the pasture's CA, accounts from its signup form, and a password grant
for a local application. scenarios/smithereen.sh drives its VKontakte-like API: friends as mutual follows, wall posts,
comments, likes, reposts (quotes there), polls, edits, deletions, private messages, the unfollow and statistics, 30
checks. A post on someone else's wall never reaches PrivaPub, since Smithereen sends it only to servers whose actors
publish a wall: G-0009, waiting for the owner.

PrivaPub: a server description that failed (Smithereen serves no NodeInfo until it has a description) frees its week,
so the server's next arrival asks again instead of a week later.

The shared Postgres takes 400 connections: at 100 the village seed ran it dry (Sharkey's API answered 500, Misskey
dropped deliveries). The seeder records a follow that stands from an earlier seed when the step itself fails, so the
checker no longer expects that follower to see nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
2026-10-05 22:03:35 +02:00

51 lines
3.0 KiB
Bash

# Services several peers share: one Postgres and one MySQL (each peer gets its own database), and one Redis (each its own
# db number). A dozen peers keep their pools on the one Postgres, and Postgres's default 100 connections ran out while
# the town seeded (Sharkey's API answered 500, Misskey's queue dropped deliveries): it takes 400.
shared_postgres_up() {
podman container exists pasture-postgres && return 0
podman run -d --replace --name pasture-postgres --network $net --network-alias postgres \
-e POSTGRES_USER=pasture -e POSTGRES_PASSWORD=pasture -e POSTGRES_DB=pasture docker.io/library/postgres:17-alpine \
-c max_connections=400 >/dev/null
for _ in $(seq 1 60); do podman exec pasture-postgres pg_isready -U pasture >/dev/null 2>&1 && return 0; sleep 1; done
echo "postgres did not start" >&2; return 1
}
shared_redis_up() {
podman container exists pasture-redis && return 0
podman run -d --replace --name pasture-redis --network $net --network-alias redis docker.io/library/redis:7-alpine >/dev/null
}
# pg_db <name> [extension...]: a database of the shared Postgres for one peer, with the extensions it needs
pg_db() {
local name=$1; shift
podman exec pasture-postgres sh -c "psql -U pasture -tc \"select 1 from pg_database where datname='$name'\" | grep -q 1 || createdb -U pasture $name"
for ext in "$@"; do
podman exec pasture-postgres psql -U pasture -d "$name" -qc "create extension if not exists \"$ext\";" >/dev/null
done
}
# a PostGIS of its own for the peers that need the extension (Mobilizon), beside the shared Postgres that has not got it.
# Its first start runs a server on the socket alone to set itself up: only TCP answers when it is ready
shared_postgis_up() {
podman container exists pasture-postgis && return 0
podman run -d --replace --name pasture-postgis --network $net --network-alias postgis --label pasture=1 \
-e POSTGRES_USER=pasture -e POSTGRES_PASSWORD=pasture -e POSTGRES_DB=pasture docker.io/postgis/postgis:17-3.5-alpine >/dev/null
for _ in $(seq 1 90); do podman exec pasture-postgis pg_isready -h 127.0.0.1 -U pasture >/dev/null 2>&1 && return 0; sleep 1; done
echo "postgis did not start" >&2; return 1
}
shared_mysql_up() {
podman container exists pasture-mysql && return 0
podman run -d --replace --name pasture-mysql --network $net --network-alias mysql \
-e MYSQL_ROOT_PASSWORD=pasture -e MYSQL_USER=pasture -e MYSQL_PASSWORD=pasture docker.io/library/mysql:8.4 >/dev/null
# its first start runs a temporary server without networking to set itself up: only TCP answers when it is ready
for _ in $(seq 1 90); do podman exec pasture-mysql mysqladmin ping -h127.0.0.1 --protocol=tcp -uroot -ppasture --silent >/dev/null 2>&1 && return 0; sleep 2; done
echo "mysql did not start" >&2; return 1
}
# mysql_db <name>: a database of the shared MySQL for one peer, the pasture user owning it
mysql_db() {
podman exec pasture-mysql mysql -uroot -ppasture -e \
"create database if not exists \`$1\` character set utf8mb4 collate utf8mb4_unicode_ci; grant all on \`$1\`.* to 'pasture'@'%';" 2>/dev/null
}