kafka-pipe: don't use a random server ID

This commit is contained in:
Adam 2022-05-01 23:02:45 +02:00
parent ee3c7956cd
commit 332bc5ecb6
2 changed files with 15 additions and 4 deletions

View file

@ -12,8 +12,11 @@ services:
networks:
- "kafkatorio-nw"
environment:
FACTORIO_SERVER_CONTAINER_NAME: "factorio-server"
KAFKATORIO_VERSION: $KAFKATORIO_VERSION
# message IDs
INSTANCE_ID: "test-server"
# name of the docker container
FACTORIO_SERVER_CONTAINER_NAME: "factorio-server"
KAFKA_HOST: "kafka:29092"
volumes:
# Windows (requires privileged/root)

View file

@ -12,16 +12,24 @@ endProcess() {
}
# some random ID, to use as a message key
INSTANCE_ID=$(cat /proc/sys/kernel/random/uuid)
#INSTANCE_ID="${INSTANCE_ID}"$(cat /proc/sys/kernel/random/uuid)
KEY="${INSTANCE_ID:-none}"
while :; do
docker logs --tail 0 -f "$FACTORIO_SERVER_CONTAINER_NAME" |
sed -n -e 's/^KafkatorioPacket: //p' |
kcat -P -T \
kcat -P \
-b "$KAFKA_HOST" \
-t kafkatorio.src.server-log \
-k "$INSTANCE_ID" \
-k "$KEY" \
-H "KAFKA-PIPE-VERSION=$KAFKATORIO_VERSION"
# -T \
# -P producer mode
# -T echo to stdout
# -t the topic name
# -k the key of the message
# -H add a header
echo "Error - retrying in 10 seconds"
sleep 10