Skip to content

Commit 1e067ba

Browse files
committed
use env variable and improve comments
1 parent 3fd2d29 commit 1e067ba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

postgres-cdc-example/startup.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# run postgres in the background so we can run pg_recvlogical
44
postgres -c wal_level=logical -c max_wal_senders=1 -c shared_preload_libraries=wal2json &
5-
# ensure postgres is fully initialized
5+
# ensure postgres is fully initialized before running pg_recvlogical
66
sleep 10s
7-
# create replication slot
8-
pg_recvlogical -d test_db --slot messages_slot --create-slot --if-not-exists -P wal2json
7+
# create replication slot if required
8+
pg_recvlogical -d test_db --slot ${CDC_DB_NAME}_slot --create-slot --if-not-exists -P wal2json
99
# need a function for publishing otherwise bash shouts
1010
publish_to_redis() {
1111
redis-cli -h $REDIS_HOST -p $REDIS_PORT PUBLISH $REDIS_CHANNEL $1
1212
}
1313
# listen to replication messages and publish them to redis
14-
pg_recvlogical -d test_db --slot messages_slot --start -o pretty-print=0 -f - | while read message; do publish_to_redis $message ; done
14+
pg_recvlogical -d ${CDC_DB_NAME} --slot ${CDC_DB_NAME}_slot --start -o pretty-print=0 -f - | while read message; do publish_to_redis $message ; done
1515
# uncomment the following if you comment the previous to keep the container running
1616
# tail -f /dev/null

0 commit comments

Comments
 (0)