diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 0b28397..2cdc6e8 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -13,9 +13,6 @@ clap = { workspace = true } # fs/network kxio = { workspace = true } -# Actors -actix-rt = { workspace = true } - [lints.clippy] nursery = { level = "warn", priority = -1 } # pedantic = "warn" diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index c0ab962..8ec4429 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -26,8 +26,7 @@ enum Server { Start, } -#[actix_rt::main] -async fn main() { +fn main() { let fs = fs::new(PathBuf::default()); let net = Network::new_real(); let repo = git_next_git::repository::real(); @@ -43,7 +42,7 @@ async fn main() { } Server::Start => { let sleep_duration = std::time::Duration::from_secs(10); - git_next_server::start(fs, net, repo, sleep_duration).await; + git_next_server::start(fs, net, repo, sleep_duration); } }, } diff --git a/crates/server/src/lib.rs b/crates/server/src/lib.rs index 8900ab7..3f6960a 100644 --- a/crates/server/src/lib.rs +++ b/crates/server/src/lib.rs @@ -30,7 +30,7 @@ pub fn init(fs: FileSystem) { } } -pub async fn start( +pub fn start( fs: FileSystem, net: Network, repo: Box, @@ -39,22 +39,31 @@ pub async fn start( init_logging(); info!("Starting Server..."); - let server = Server::new(fs.clone(), net.clone(), repo, sleep_duration).start(); - server.do_send(FileUpdated); + let execution = async move { + //- + let server = Server::new(fs.clone(), net.clone(), repo, sleep_duration).start(); + server.do_send(FileUpdated); - info!("Starting File Watcher..."); - let fw = match FileWatcher::new("git-next-server.toml".into(), server.recipient()) { - Ok(fw) => fw, - Err(err) => { - error!(?err, "Failed to start file watcher"); - return; - } + info!("Starting File Watcher..."); + let fw = match FileWatcher::new("git-next-server.toml".into(), server.recipient()) { + Ok(fw) => fw, + Err(err) => { + error!(?err, "Failed to start file watcher"); + return; + } + }; + fw.start(); + + info!("Server running - Press Ctrl-C to stop..."); + let _ = actix_rt::signal::ctrl_c().await; + info!("Ctrl-C received, shutting down..."); + System::current().stop(); + }; + let system = System::new(); + Arbiter::current().spawn(execution); + if let Err(err) = system.run() { + tracing::error!(?err, "") }; - fw.start(); - - info!("Server running - Press Ctrl-C to stop..."); - let _ = actix_rt::signal::ctrl_c().await; - info!("Ctrl-C received, shutting down..."); } pub fn init_logging() {