Добавить мессенджер на Java с PostgreSQL и сессиями в Redis.
Application / application (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s

Данные и действующий токен переживают рестарт, сессии хранятся в Redis с AOF.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-14 20:52:39 +03:00
co-authored by Cursor
parent 65003b6119
commit 6300cfc6e0
26 changed files with 2659 additions and 17 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
mkdir -p secrets
umask 077
if [ ! -s secrets/postgres_password ]; then
tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 24 > secrets/postgres_password
fi
pass=$(tr -d '\n' < secrets/postgres_password)
printf 'jdbc:postgresql://postgres:5432/messenger?user=messenger&password=%s\n' "$pass" > secrets/database_url
printf 'redis://redis:6379/0\n' > secrets/cache_url
chmod 600 secrets/postgres_password
chmod 644 secrets/database_url secrets/cache_url
if [ ! -f .env ]; then
cp .env.example .env
fi
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
docker compose --env-file .env restart postgres redis
i=0
while [ "$i" -lt 40 ]; do
pg_id=$(docker compose --env-file .env ps -q postgres)
rd_id=$(docker compose --env-file .env ps -q redis)
pg=$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' "$pg_id")
rd=$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' "$rd_id")
if [ "$pg" = "healthy" ] && [ "$rd" = "healthy" ]; then
docker compose --env-file .env restart api
exit 0
fi
i=$((i + 1))
sleep 1
done
echo 'postgres or redis did not become healthy' >&2
exit 1