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:

VariableMeaningDefault
CLUSTERIO_NODEThis node's namelocal
CLUSTERIO_PEERSEvery node, this one included: a=10.0.0.1:7000,b=10.0.0.2:7000,c=10.0.0.3:7000this node alone
CLUSTERIO_DATADirectory 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:

NodesSurvives the loss of
1none
31
52

Three is the usual choice. An even number survives no more losses than the odd number below it.

clusterio run#

sh
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.argv

APP 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.

OptionOverrides
--node NAMECLUSTERIO_NODE
--peers PEERSCLUSTERIO_PEERS
--data DIRCLUSTERIO_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.