File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
# run postgres in the background so we can run pg_recvlogical
4
4
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
6
6
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
9
9
# need a function for publishing otherwise bash shouts
10
10
publish_to_redis () {
11
11
redis-cli -h $REDIS_HOST -p $REDIS_PORT PUBLISH $REDIS_CHANNEL $1
12
12
}
13
13
# 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
15
15
# uncomment the following if you comment the previous to keep the container running
16
16
# tail -f /dev/null
You can’t perform that action at this time.
0 commit comments