Every minute, the mod diffs the force's production statistics for each
surface against the totals it sent last time (kept in
storage.productionTotals), and sends what was produced and consumed as a
ProductionUpdate.
events-server-web keeps the statistics in ring buffers (1440 minutes and
168 hours), and serves them at
/kafkatorio/data/servers/{id}/production, for a range of game time and
optionally one surface.
The web map has a production page (/servers/{id}/production, linked from
the header) with science packs used per minute (in total and per pack),
production per minute as a line chart, and a searchable table of
everything produced and consumed.
export_building_icons.py now also exports every item and fluid icon and
name (items.json, fluids.json), for the production page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.7 KiB
Running Kafkatorio
Building the project
Requirements
- Docker
- Docker Compose
- Java 11
Kafkatorio uses Gradle to build the project, and Docker Compose to create images.
./gradlew build- build and test the project./gradlew runKafkatorio- run locally (if Docker is running, a Kafka instance will start)./gradlew dockerComposeBuild- build, test, and create Kafkatorio Docker images
Server set up
See ./kafkatorio-platform/docker-compose.yml for a complete example
-
Copy the kafkatorio-platform directory to your computer
-
Rename
example.secret.kafkatorio-config.ymlto.secret.kafkatorio-config.ymlIn it, define both
- a JWT secret password (a long alphanumeric string is best, you won't need to type this password manually)
- a Factorio server, with a short-ID and a description.
-
Rename
example.envto.env -
Create a JWT for your Factorio server, by going to https://jwt.io/
- In 'PAYLOAD: DATA', set
subto your Factorio server's short ID.
({ "sub": "<your server short ID>", "iat": ... }iat, 'issued-at-time', should update automatically to be the current time.) - Replace
your-256-bit-secretwith your JWT secret password
Copy the 'Encoded' token (it should start with
ey).In the
.envfile, setKAFKATORIO_TOKENto equal the token. - In 'PAYLOAD: DATA', set
-
In
kafkatorio-platform, start the docker containersdocker-compose up -d; docker-compose logs -f
Unraid set up
This runs the Kafkatorio services on the same Unraid server as the Factorio server. The Docker
syslog log driver runs in the Docker daemon on the host, so the syslog port only needs to listen
on 127.0.0.1, and Kafka isn't exposed at all.
-
Install the Compose Manager plugin (or Compose Manager Plus) from the Apps tab.
-
Build the images locally, and copy them to Unraid (no registry needed):
./gradlew dockerComposeBuild docker save $(docker images --format '{{.Repository}}:{{.Tag}}' | grep dev.adamko.kafkatorio) \ | gzip | ssh root@<unraid> 'gunzip | docker load' -
On Unraid, create
/mnt/user/appdata/kafkatorio-platform/containing.secret.kafkatorio-config.yml(see above)config/kafka-server.properties(copy from ./kafkatorio-platform/config)config/cluster_id- a fixed Kafka cluster ID, so the Kafka data survives image rebuilds. Generate one withdocker run --rm --entrypoint ./bin/kafka-storage.sh <kafka-kraft image> random-uuid.
-
Create a Compose Manager stack, with the Unraid
docker-compose.yml, andexample.envas its.env. Start the stack. -
Edit the Factorio container, enable 'Advanced View', and set 'Extra Parameters' to
--log-driver=syslog --log-opt syslog-address=tcp://127.0.0.1:12035 --log-opt syslog-format=rfc5424 --log-opt mode=non-blocking --log-opt tag=<KAFKATORIO_TOKEN>Docker won't start a container if its TCP syslog server isn't reachable, so on the Docker tab give the Factorio container an autostart 'wait' of ~30 seconds, so the Kafkatorio services start first.
-
The web map is on port
12081. It also proxies/kafkatorio/to the events server, so a reverse proxy (e.g. Nginx Proxy Manager) only needs to forward to that one port - make sure WebSocket support is enabled. -
In Factorio, run
/kafkatorio prototypesand then/kafkatorio chunks 10to send the existing map. -
Optional: icons and names. The web map's 'Building icons' layer, the research page and the production page use icons, building sizes, the technology tree and in-game names, exported from a Factorio client that has the same mods as the server (they're not in this repo, since they belong to Wube and the mod authors). Without them, those pages show less, or nothing. With the game closed, run
factorio --dump-data factorio --dump-prototype-locale SteamAppId=427520 factorio --dump-icon-sprites # SteamAppId stops Steam relaunching the game python3 docs/kafkatorio-platform/building-icons/export_building_icons.py ~/.factorio/script-output ./icons scp -r ./icons root@<unraid>:/mnt/user/appdata/kafkatorio-platform/Re-export them when the mods change. If Pillow is installed, the (large) technology icons are shrunk.