boris-sinyapkin / lurk

Lightweight implementation of a SOCKS5 proxy built on async Rust
0 stars 0 forks source link

[LurkServer] Implement graceful shutdown #34

Open boris-sinyapkin opened 3 months ago

boris-sinyapkin commented 3 months ago

Server should terminate gracefully, closing all the resources and tasks. This could be done through tokio task tracker (see join set as well).

Canceling event could be awaited in main loop as following:

tokio::select! {
  conn = listener.accept() => { /* process conn */ },
  _ = cancel_event => { /* shutdown */ }
}

Tasks spawned for clients could be spawned through TaskTracker and then awaited on shutdown.