Skip to content
SHC Docs

Core

Layer 2. Core. Core

shcd (shc cmd/shcd/main.go) is the daemon. daemon.Run (ce daemon/daemon.go) starts its subsystem graph: the HTTP listeners, the store, and the work that follows the leader.

A deployment is the running unit. Stack and environment are its axes, with the tenant (ce ent/schema/deployment.go). One node runs one runtime: docker, podman, incus or apple.

rqlite is the only consensus. RqliteEngine (shc subsystems/rqlite_engine.go) supervises an external rqlited when {state}/engine.json is present (shc core/rqlited/engine.go). rqliteAddrs binds that process to the node’s mesh0 address, HTTP on TCP 4001 and raft on TCP 4002. Without the marker the subsystem does nothing and the daemon stays on the SQLite file {state}/shc.db.

The leader is the raft leader. LeaderHub (ce subsystems/impl/leader_hub.go) polls that id every second and compares it with {state}/node.id. The matching node runs leader-only work through OnLeader. A leader query that rqlited does not answer keeps the leadership for up to 5 s since the last answer that named this node (subsystems/leader_elector.go), so a short rqlited stall does not stop and start every leader-only subsystem; an answer naming another node, or no leader, drops it at once. A single-node install is its own leader and does not poll.

The leader stores a deployment’s rendered spec (ce modules/app/stored_render.go). A node finishes that stored spec for itself. It does not render it again.