Configuration and CLI
User code never says where the cluster is. The module functions (clusterio.dict, clusterio.transaction and the rest) use a default node that reads three environment variables the first time it is used:
| Variable | Meaning | Default |
|---|---|---|
CLUSTERIO_NODE | This node's name | local |
CLUSTERIO_PEERS | Every node, this one included: a=10.0.0.1:7000,b=10.0.0.2:7000,c=10.0.0.3:7000 | this node alone |
CLUSTERIO_DATA | Directory for the node's SQLite database | .clusterio/<node> |
With nothing set, clusterio is a one-node cluster on disk, so a script runs the same way on a laptop and, with three variables set, across three hosts.
A node listens on the address its own entry in CLUSTERIO_PEERS gives, so that address must be one the host owns and the other nodes can reach. Every node must be given the same peers.
How many nodes#
A cluster of n nodes keeps working while a majority, more than n / 2, are up and can reach each other:
| Nodes | Survives the loss of |
|---|---|
| 1 | none |
| 3 | 1 |
| 5 | 2 |
Three is the usual choice. An even number survives no more losses than the odd number below it.
clusterio run#
clusterio run app:main # start a node, then call main() from app.py
clusterio run app.py:main # the same, by path
clusterio run app.py # the function defaults to main
clusterio run # a node that only stores and votes
clusterio run app:main --node a --peers a=10.0.0.1:7000,b=10.0.0.2:7000,c=10.0.0.3:7000 --data /var/lib/app
clusterio run app.py -- --verbose # app.py sees ["app.py", "--verbose"] in sys.argvAPP is module:function or path/to/file.py:function. run starts the node, calls the function with no arguments, and stops the node when it returns; the function's int result is the exit status. Arguments after -- are the app's sys.argv[1:]. With no APP, the node runs until Ctrl-C. A file named as a module that is already imported, such as queue.py, is refused: rename it.
| Option | Overrides |
|---|---|
--node NAME | CLUSTERIO_NODE |
--peers PEERS | CLUSTERIO_PEERS |
--data DIR | CLUSTERIO_DATA |
Deploying#
Run one node per host, under whatever runs your services (systemd, a container orchestrator, a process supervisor), with the variables in the unit's environment. Keep CLUSTERIO_DATA on a disk that survives restarts: a node that restarts with its data rejoins at once, while a node that loses its data is a new, empty node with an old name.
clusterio's traffic is not encrypted or authenticated. Run it on a private network, or a VPN such as WireGuard or Tailscale between the hosts.