scaffolding, initial passes
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
ae106b6d31fbfa669243d2a54fc5454a388d9205- Parents
-
7364665 - Tree
5a6636a
ae106b6
ae106b6d31fbfa669243d2a54fc5454a388d92057364665
5a6636a| Status | File | + | - |
|---|---|---|---|
| M |
.gitignore
|
6 | 6 |
| M |
Cargo.toml
|
6 | 3 |
| M |
src/main.rs
|
64 | 0 |
.gitignoremodified@@ -1,6 +1,6 @@ | ||
| 1 | - /target/ | |
| 2 | - Cargo.lock | |
| 3 | - **/*.rs.bk | |
| 4 | - .env | |
| 5 | - .vscode/ | |
| 6 | - .idea/ | |
| 1 | + target/ | |
| 2 | + Cargo.lock | |
| 3 | + **/*.rs.bk | |
| 4 | + .env | |
| 5 | + .vscode/ | |
| 6 | + .idea/ | |
Cargo.tomlmodified@@ -18,12 +18,14 @@ libp2p = { version = "0.54", features = [ | ||
| 18 | 18 | "ping", |
| 19 | 19 | "identify", |
| 20 | 20 | "gossipsub", |
| 21 | - "dcutr" | |
| 21 | + "dcutr", | |
| 22 | + "tokio", | |
| 23 | + "macros" | |
| 22 | 24 | ]} |
| 23 | 25 | tokio = { version = "1.39", features = ["full"] } |
| 24 | 26 | |
| 25 | -# Storage and database | |
| 26 | -rocksdb = "0.22" | |
| 27 | +# Storage and database (temporarily simplified for Phase 1.1) | |
| 28 | +# rocksdb = "0.22" # Will add back in Phase 1.2 | |
| 27 | 29 | serde = { version = "1.0", features = ["derive"] } |
| 28 | 30 | serde_yaml = "0.9" |
| 29 | 31 | |
@@ -31,6 +33,7 @@ serde_yaml = "0.9" | ||
| 31 | 33 | blake3 = "1.5" |
| 32 | 34 | sha2 = "0.10" |
| 33 | 35 | rand = "0.8" |
| 36 | +hex = "0.4" | |
| 34 | 37 | |
| 35 | 38 | # Protocol buffers |
| 36 | 39 | prost = "0.13" |
src/main.rsmodified@@ -0,0 +1,64 @@ | ||
| 1 | +use anyhow::Result; | |
| 2 | +use clap::Parser; | |
| 3 | +use tracing::{info, warn}; | |
| 4 | +use tracing_subscriber; | |
| 5 | + | |
| 6 | +mod config; | |
| 7 | +mod network; | |
| 8 | +mod storage; | |
| 9 | +mod protocol; | |
| 10 | + | |
| 11 | +use config::Config; | |
| 12 | +use network::NetworkManager; | |
| 13 | + | |
| 14 | +#[derive(Parser, Debug)] | |
| 15 | +#[command(author, version, about, long_about = None)] | |
| 16 | +struct Args { | |
| 17 | + #[arg(short, long, value_name = "FILE")] | |
| 18 | + config: Option<std::path::PathBuf>, | |
| 19 | + | |
| 20 | + #[arg(long)] | |
| 21 | + health_check: bool, | |
| 22 | + | |
| 23 | + #[arg(short, long)] | |
| 24 | + verbose: bool, | |
| 25 | +} | |
| 26 | + | |
| 27 | +#[tokio::main] | |
| 28 | +async fn main() -> Result<()> { | |
| 29 | + let args = Args::parse(); | |
| 30 | + | |
| 31 | + // Initialize logging | |
| 32 | + let log_level = if args.verbose { "debug" } else { "info" }; | |
| 33 | + tracing_subscriber::fmt() | |
| 34 | + .with_env_filter(format!("zephyrfs_node={}", log_level)) | |
| 35 | + .init(); | |
| 36 | + | |
| 37 | + if args.health_check { | |
| 38 | + // Simple health check for Docker | |
| 39 | + info!("Health check passed"); | |
| 40 | + return Ok(()); | |
| 41 | + } | |
| 42 | + | |
| 43 | + info!("Starting ZephyrFS Node"); | |
| 44 | + | |
| 45 | + // Load configuration | |
| 46 | + let config = Config::load(args.config.as_deref())?; | |
| 47 | + info!("Configuration loaded: {:?}", config); | |
| 48 | + | |
| 49 | + // Initialize network manager | |
| 50 | + let mut network_manager = NetworkManager::new(config).await?; | |
| 51 | + | |
| 52 | + // Start the node | |
| 53 | + info!("Starting P2P networking..."); | |
| 54 | + network_manager.start().await?; | |
| 55 | + | |
| 56 | + // Keep running until shutdown signal | |
| 57 | + tokio::signal::ctrl_c().await?; | |
| 58 | + warn!("Shutdown signal received"); | |
| 59 | + | |
| 60 | + network_manager.shutdown().await?; | |
| 61 | + info!("ZephyrFS Node stopped"); | |
| 62 | + | |
| 63 | + Ok(()) | |
| 64 | +} | |