mirror of
https://github.com/thegeneralist01/p2p-failover
synced 2026-01-08 22:30:29 +01:00
No description
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| example.p2p-failover.config.yaml | ||
| README.md | ||
P2P Failover
A peer-to-peer active-passive failover system written in Rust that manages process execution across multiple nodes based on availability and priority.
Overview
P2P Failover ensures that a process runs on the highest priority available node, with automatic failover if that node becomes unavailable.
Key features:
- Automatic process management based on node priority
- Real-time node health monitoring
- TCP-based peer communication
- YAML configuration (apologies)
Installation
- Clone the repository
- Build the project:
cargo build --release
Configuration
Create a p2p-failover.config.yaml file in your project directory. Here's an example configuration:
nodes:
- name: pc
ip: 127.0.0.1
port: 8080
priority: 100
last_updated: 2025-02-04 19:19:18 UTC
- name: phone
ip: 100.11.111.111
port: 8081
priority: 20
last_updated: 2025-01-09 16:45:00 UTC
config_metadata:
name: pc
last_updated: 2025-01-11 10:00:00 UTC
execution:
instructions: ./test-program.sh
last_updated: 2025-01-11 10:00:00 UTC
Configuration Fields
nodes: List of nodes in the networkname: Unique identifier for the nodeip: IP addressport: TCP port for node communicationpriority: Node priority (higher number = higher priority)last_updated: Timestamp of last update
config_metadata: Node-specific metadataname: Name of this nodelast_updated: Configuration timestamp
execution: Process execution settingsinstructions: Command to executelast_updated: Last modification timestamp
Environment Variables
P2P_CONFIG_PATH: Path to config file (default:p2p-failover.config.yaml)VERBOSE: Enable verbose logging (1/true)DEBUG: Enable debug logging (1/true)
Note: When DEBUG is set to 1, VERBOSE is automatically turned on.
How It Works
- Each node monitors the health of other nodes in the network through periodic heartbeats
- The node with the highest priority and availability runs the specified process
- If a higher priority node becomes available, the process gets killed and started on the other node
- If the active node fails, the next highest priority available node takes over
License
MIT