Add a forwarder for Factorio servers that don't run in Docker
The mod prints its packets to the server's standard output, and Docker's syslog log driver sends them to Kafkatorio. kafkatorio-forward.py does the same without Docker: it runs the server (or reads its output from a pipe), prints the output as usual, and sends the mod's packets to the syslog port in the same format as Docker, tagged with the token. - the server keeps running when Kafkatorio is unreachable: packets wait in a bounded buffer, and are sent after reconnecting - before each send it checks Kafkatorio hasn't closed the connection, so lines aren't silently lost in a dead socket - Ctrl+C and SIGTERM are passed to the server once, so it saves and stops - the token is read from a file or the environment, not the command line - only the Python standard library util-linux's logger can't be used instead: it rejects the token, which is longer than syslog's 48 character APP-NAME limit. Tested on Linux with a Factorio 2.0.77 server: packets arrive, the forwarder reconnects when the syslog server restarts (no packets lost), and the server saves when stopped. The guide has a section for it, with a systemd service example, and the README no longer says the Factorio server must run in Docker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1f4786c1bd
commit
47ab9f30fc
3 changed files with 281 additions and 9 deletions
10
README.md
10
README.md
|
|
@ -19,7 +19,8 @@ Factorio 2.0, with the production and research pages and many fixes.
|
|||
|
||||
## Running it yourself
|
||||
|
||||
You need a Factorio server running in Docker, and a machine to build the images on.
|
||||
You need a Factorio server (in Docker, or not), a Docker host for Kafkatorio, and a machine to
|
||||
build the images on.
|
||||
**[The guide](./docs/guide.md)** covers building, configuring, connecting the Factorio server,
|
||||
and putting the website behind a reverse proxy, with a ready-made setup for Unraid.
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ flowchart LR
|
|||
map["web-map<br/>(nginx)"]
|
||||
browser([Browser])
|
||||
|
||||
factorio -- "packets in the server log<br/>(Docker syslog log driver)" --> syslog
|
||||
factorio -- "packets in the server's output<br/>(Docker syslog log driver,<br/>or kafkatorio-forward.py)" --> syslog
|
||||
syslog -- "checks the server's token" --> kafka
|
||||
kafka <--> processors
|
||||
kafka --> web
|
||||
|
|
@ -46,8 +47,9 @@ flowchart LR
|
|||
1. The mod, [`events-mod`](./modules/events-mod) (written in TypeScript, compiled to Lua), listens
|
||||
to in-game events, groups and de-bounces them, and prints them as JSON packets to the server
|
||||
log.
|
||||
2. Docker's syslog log driver forwards the Factorio container's log to
|
||||
[`events-server-syslog`](./modules/events-server-syslog). Each server's log is tagged with a
|
||||
2. Docker's syslog log driver (or, for a server outside Docker,
|
||||
[`kafkatorio-forward.py`](./docs/kafkatorio-platform/forwarder/kafkatorio-forward.py)) forwards
|
||||
the server's output to [`events-server-syslog`](./modules/events-server-syslog). Each server's log is tagged with a
|
||||
token (a JWT), so only known servers are accepted. The packets go to a Kafka topic.
|
||||
3. [`events-processors`](./modules/events-processors) uses Kafka Streams to turn the packets into
|
||||
map tiles, buildings, resource patches, and so on.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue