Mac Wakeup using caffeinate

This commit is contained in:
Nikos Fazakis 2022-12-27 11:36:53 +02:00
parent 5b3b7bd3c0
commit d244551ad8

View File

@ -104,6 +104,11 @@ async fn accept_connection_(server: ServerPtr, socket: Stream, secure: bool) ->
if let Ok((stream, addr)) = timeout(CONNECT_TIMEOUT, listener.accept()).await? { if let Ok((stream, addr)) = timeout(CONNECT_TIMEOUT, listener.accept()).await? {
stream.set_nodelay(true).ok(); stream.set_nodelay(true).ok();
let stream_addr = stream.local_addr()?; let stream_addr = stream.local_addr()?;
if cfg!(target_os = "macos") {
use std::process::Command;
Command::new("/usr/bin/caffeinate").arg("-u").arg("-t 2").output().expect("failed to execute caffeinate");
println!("wake up macos...");
}
create_tcp_connection(server, Stream::from(stream, stream_addr), addr, secure).await?; create_tcp_connection(server, Stream::from(stream, stream_addr), addr, secure).await?;
} }
Ok(()) Ok(())