share-lt/docs/docker/create_nats_stream.sh
jon brookes 5b0e55c4b2 feat: implement Change resource with CRUD functionality and migration
update image tags to v0.0.8 in build scripts and docker-compose files
2026-02-17 16:07:22 +00:00

48 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
# This script creates a NATS stream using the nats CLI tool.
# It reads the stream name, password, and subject from an .env file.
ENV_FILE=".env"
if [ ! -f "$ENV_FILE" ]; then
echo ".env file not found at $ENV_FILE"
exit 1
fi
. "$ENV_FILE"
if [ -z "$NATS_STREAM" ]; then
echo "NATS_STREAM is not set in .env file"
exit 1
fi
if [ -z "$NATS_PASSWORD" ]; then
echo "NATS_PASSWORD is not set in .env file"
exit 1
fi
if [ -z "$NATS_SUBJECT" ]; then
echo "NATS_SUBJECT is not set in .env file"
exit 1
fi
nats \
stream add "$NATS_STREAM" \
--user ruser --password $NATS_PASSWORD \
--subjects NATS_SUBJECT1 \
--subjects NATS_SUBJECT2 \
--subjects NATS_SUBJECT3 \
--storage file \
--dupe-window="2m" \
--replicas=1 \
--max-msgs-per-subject=-1 \
--no-allow-rollup \
--no-deny-delete \
--no-deny-purge \
--discard=old \
--max-msgs=-1 \
--max-bytes=-1 \
--max-msg-size=-1 \
--max-age=1h \
--retention limits