flutter and macos work
This commit is contained in:
@@ -73,6 +73,7 @@ struct VeilidServerImpl {
|
||||
}
|
||||
|
||||
impl VeilidServerImpl {
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
pub fn new(veilid_api: veilid_core::VeilidAPI) -> Self {
|
||||
Self {
|
||||
next_id: 0,
|
||||
@@ -83,6 +84,7 @@ impl VeilidServerImpl {
|
||||
}
|
||||
|
||||
impl veilid_server::Server for VeilidServerImpl {
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
fn register(
|
||||
&mut self,
|
||||
params: veilid_server::RegisterParams,
|
||||
@@ -126,6 +128,7 @@ impl veilid_server::Server for VeilidServerImpl {
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
fn debug(
|
||||
&mut self,
|
||||
params: veilid_server::DebugParams,
|
||||
@@ -145,6 +148,7 @@ impl veilid_server::Server for VeilidServerImpl {
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
fn attach(
|
||||
&mut self,
|
||||
_params: veilid_server::AttachParams,
|
||||
@@ -160,6 +164,7 @@ impl veilid_server::Server for VeilidServerImpl {
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
fn detach(
|
||||
&mut self,
|
||||
_params: veilid_server::DetachParams,
|
||||
@@ -175,6 +180,7 @@ impl veilid_server::Server for VeilidServerImpl {
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
fn shutdown(
|
||||
&mut self,
|
||||
_params: veilid_server::ShutdownParams,
|
||||
@@ -194,6 +200,7 @@ impl veilid_server::Server for VeilidServerImpl {
|
||||
Promise::ok(())
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
fn get_state(
|
||||
&mut self,
|
||||
_params: veilid_server::GetStateParams,
|
||||
@@ -239,6 +246,7 @@ pub struct ClientApi {
|
||||
}
|
||||
|
||||
impl ClientApi {
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
pub fn new(veilid_api: veilid_core::VeilidAPI) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
inner: RefCell::new(ClientApiInner {
|
||||
@@ -250,6 +258,7 @@ impl ClientApi {
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
pub async fn stop(self: Rc<Self>) {
|
||||
trace!("ClientApi::stop requested");
|
||||
let jh = {
|
||||
@@ -268,6 +277,7 @@ impl ClientApi {
|
||||
trace!("ClientApi::stop: stopped");
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self, client), err)]
|
||||
async fn handle_incoming(
|
||||
self: Rc<Self>,
|
||||
bind_addr: SocketAddr,
|
||||
@@ -301,6 +311,7 @@ impl ClientApi {
|
||||
incoming_loop.await
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
fn send_request_to_all_clients<F, T>(self: Rc<Self>, request: F)
|
||||
where
|
||||
F: Fn(u64, &mut RegistrationHandle) -> Option<::capnp::capability::RemotePromise<T>>,
|
||||
@@ -338,6 +349,7 @@ impl ClientApi {
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
pub fn handle_update(self: Rc<Self>, veilid_update: veilid_core::VeilidUpdate) {
|
||||
// serialize update
|
||||
let veilid_update = serialize_json(veilid_update);
|
||||
@@ -360,6 +372,7 @@ impl ClientApi {
|
||||
});
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
pub fn run(self: Rc<Self>, bind_addrs: Vec<SocketAddr>) {
|
||||
// Create client api VeilidServer
|
||||
let veilid_server_impl = VeilidServerImpl::new(self.inner.borrow().veilid_api.clone());
|
||||
|
@@ -15,6 +15,7 @@ mod windows;
|
||||
use async_std::task;
|
||||
use cfg_if::*;
|
||||
use server::*;
|
||||
use tracing::*;
|
||||
use veilid_logs::*;
|
||||
|
||||
#[allow(clippy::all)]
|
||||
@@ -22,6 +23,7 @@ pub mod veilid_client_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs"));
|
||||
}
|
||||
|
||||
#[instrument(err)]
|
||||
fn main() -> Result<(), String> {
|
||||
#[cfg(windows)]
|
||||
let _ = ansi_term::enable_ansi_support();
|
||||
|
@@ -8,7 +8,7 @@ use std::time::{Duration, Instant};
|
||||
use tracing::*;
|
||||
use veilid_core::xx::SingleShotEventual;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum ServerMode {
|
||||
Normal,
|
||||
ShutdownImmediate,
|
||||
@@ -20,6 +20,7 @@ lazy_static! {
|
||||
Mutex::new(Some(SingleShotEventual::new(Some(()))));
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
pub fn shutdown() {
|
||||
let shutdown_switch = SHUTDOWN_SWITCH.lock().take();
|
||||
if let Some(shutdown_switch) = shutdown_switch {
|
||||
@@ -28,13 +29,10 @@ pub fn shutdown() {
|
||||
}
|
||||
|
||||
pub async fn run_veilid_server(settings: Settings, server_mode: ServerMode) -> Result<(), String> {
|
||||
run_veilid_server_internal(settings, server_mode)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("{}", e);
|
||||
e
|
||||
})
|
||||
run_veilid_server_internal(settings, server_mode).await
|
||||
}
|
||||
|
||||
#[instrument(err)]
|
||||
pub async fn run_veilid_server_internal(
|
||||
settings: Settings,
|
||||
server_mode: ServerMode,
|
||||
|
@@ -7,7 +7,9 @@ use clap::ArgMatches;
|
||||
use signal_hook::consts::signal::*;
|
||||
use signal_hook_async_std::Signals;
|
||||
use std::io::Read;
|
||||
use tracing::*;
|
||||
|
||||
#[instrument(skip(signals))]
|
||||
async fn handle_signals(mut signals: Signals) {
|
||||
while let Some(signal) = signals.next().await {
|
||||
match signal {
|
||||
@@ -23,6 +25,7 @@ async fn handle_signals(mut signals: Signals) {
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(err)]
|
||||
pub fn run_daemon(settings: Settings, _matches: ArgMatches) -> Result<(), String> {
|
||||
let daemon = {
|
||||
let mut daemon = daemonize::Daemonize::new();
|
||||
|
Reference in New Issue
Block a user