Daemon Node Management
Purpose
Daemon Node Management addresses the critical need to reliably run and maintain blockchain node daemons for various supported blockchains within the platform. These daemons serve as the foundational layer that maintains blockchain synchronization, exposes RPC interfaces, and publishes real-time blockchain events. This subtopic ensures that each blockchain node service starts correctly, handles termination gracefully, and provides health status signals for Kubernetes to monitor synchronization and readiness.
Functionality
The core workflows revolve around the lifecycle management of blockchain daemon processes via shell scripts, tailored for each blockchain's node client. These scripts perform the following key functions:
Startup: Launch the blockchain daemon process with appropriate command-line flags and environment configurations, optimized per blockchain to enable RPC, WebSocket, ZeroMQ, or Tendermint interfaces as needed.
Signal Handling: Trap termination signals (e.g., SIGTERM, SIGINT) to enable graceful shutdown of the daemon process, ensuring data integrity and clean resource release.
Process Monitoring: Use a blocking
waitcall to keep the container running as long as the daemon process is active. Kubernetes readiness and liveness probes monitor the health externally.Chain-Specific Initialization: For some blockchains (e.g., Optimism), additional initialization steps like snapshot restoration are included before daemon start.
Environment Preparation: Install necessary dependencies or set environment variables required by the daemon.
Example Workflow for Starting and Stopping a Daemon (Litecoin)
start_coin() {
litecoind \
-rpcuser=user \
-rpcpassword=password \
-rpcallowip=0.0.0.0/0 \
-rpcbind=0.0.0.0 \
-rpcport=8332 \
-datadir=/data \
-printtoconsole=1 \
-server=1 \
-nolisten=1 \
-txindex=1 \
-disablewallet=1 \
-zmqpubhashtx=tcp://127.0.0.1:28332 \
-zmqpubhashblock=tcp://127.0.0.1:28332 &
PID="$!"
}
stop_coin() {
kill $PID
while kill -0 $PID 2>/dev/null; do sleep 1; done
}
trap 'stop_coin' TERM INT
start_coin
wait $PID
This script launches the daemon in the background, captures its PID, and waits for termination signals to trigger a clean shutdown.
Integration and Relationship
Daemon Node Management integrates tightly with the parent topic of Multi-Blockchain Coinstacks by providing the blockchain-specific node processes that the higher-level services depend on:
Indexer Services: Daemons publish blockchain data and events often via ZeroMQ or RPC interfaces. Indexers such as Blockbook consume this data to build efficient queryable caches.
API Servers: Rely on daemon RPC endpoints to fetch blockchain state, submit transactions, and validate data.
Health and Readiness Probes: Kubernetes probes invoke scripts to query daemon APIs or check process health, triggering restarts if necessary.
Deployment Automation: Pulumi deployment scripts reference these daemon scripts to configure container startup commands within Kubernetes StatefulSets.
Monitoring: Prometheus scrapes metrics exposed by these daemons or their wrappers to feed Grafana dashboards.
This subtopic complements other subtopics like Indexer Services and API Servers by ensuring the blockchain node daemons are robustly managed and always available as the source of truth for blockchain state.
Diagram
flowchart TD
Start[Container Start] --> InitScripts[Run Daemon init.sh Script]
InitScripts --> StartDaemon[Launch Blockchain Daemon Process]
StartDaemon --> WaitPID[Wait for Daemon Process]
WaitPID -->|SIGTERM / SIGINT Received| StopDaemon[Invoke Stop Function]
StopDaemon --> GracefulShutdown[Gracefully Terminate Daemon]
GracefulShutdown --> Exit[Exit Container]
This flowchart visualizes the lifecycle management process inside each daemon container, highlighting startup, signal trapping, and graceful shutdown.
By encapsulating daemon lifecycle management in dedicated scripts with chain-specific configurations, the system achieves modularity, consistency, and resilience across diverse blockchain node implementations.