Przeglądaj źródła

bin/tau: flush sled db and stop dnet and deg when caughtung termination signal

dasman 2 lat temu
rodzic
commit
71b2998e3a
1 zmienionych plików z 11 dodań i 1 usunięć
  1. 11 1
      bin/tau/taud/src/main.rs

+ 11 - 1
bin/tau/taud/src/main.rs

@@ -197,10 +197,12 @@ async fn start_sync_loop(
             task_event = incoming.receive().fuse() => {
                 let event_id = task_event.id();
                 if *last_sent.read().await == event_id {
+                    info!("last seen");
                     continue
                 }
 
                 if seen_events.contains_key(event_id.as_bytes()).unwrap() {
+                    info!("Seen events");
                     continue
                 }
 
@@ -541,13 +543,21 @@ async fn realmain(settings: Args, executor: Arc<smol::Executor<'static>>) -> Res
     signals_handler.wait_termination(signals_task).await?;
     info!("Caught termination signal, cleaning up and exiting...");
 
+    info!("Stopping P2P network");
+    p2p.stop().await;
+
     info!(target: "taud", "Stopping JSON-RPC server...");
     rpc_task.stop().await;
+    dnet_task.stop().await;
+    deg_task.stop().await;
 
     info!(target: "taud", "Stopping sync loop task...");
     sync_loop_task.stop().await;
 
-    p2p.stop().await;
+    info!("Flushing sled database...");
+    let flushed_bytes = sled_db.flush_async().await?;
+    info!("Flushed {} bytes", flushed_bytes);
 
+    info!("Shut down successfully");
     Ok(())
 }