server updates
This commit is contained in:
parent
5f5f35128f
commit
95088f7040
@ -11,4 +11,5 @@ anyhow = "1.0"
|
|||||||
navka_common = { path = "../common" }
|
navka_common = { path = "../common" }
|
||||||
tracing = { version = "0.1", features = ["std"] }
|
tracing = { version = "0.1", features = ["std"] }
|
||||||
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
futures-util = "0.3"
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
// main.rs
|
// main.rs
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
use std::{pin::Pin, sync::Arc};
|
use std::{pin::Pin, sync::Arc, panic::AssertUnwindSafe};
|
||||||
use tokio::{fs::{File, OpenOptions}, io::AsyncWriteExt, sync::Mutex};
|
use tokio::{fs::{File, OpenOptions}, io::AsyncWriteExt, sync::Mutex};
|
||||||
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
|
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
|
||||||
use tonic::{transport::Server, Request, Response, Status};
|
use tonic::{transport::Server, Request, Response, Status};
|
||||||
use tracing::{error, info, trace, warn, debug};
|
use tracing::{error, info, trace, warn, debug};
|
||||||
use tracing_subscriber::{fmt, EnvFilter};
|
use tracing_subscriber::{fmt, EnvFilter};
|
||||||
|
use futures_util::FutureExt;
|
||||||
|
|
||||||
use navka_common::navka::{
|
use navka_common::navka::{
|
||||||
relay_server::{Relay, RelayServer},
|
relay_server::{Relay, RelayServer},
|
||||||
@ -37,7 +38,7 @@ impl Relay for Handler {
|
|||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
// catch panics so that they are logged instead of killing the task silently
|
// catch panics so that they are logged instead of killing the task silently
|
||||||
let task = std::panic::AssertUnwindSafe(async move {
|
let task = AssertUnwindSafe(async move {
|
||||||
// perpetually read client → server messages
|
// perpetually read client → server messages
|
||||||
while let Some(res) = in_stream.next().await {
|
while let Some(res) = in_stream.next().await {
|
||||||
match res {
|
match res {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user