fix: backend build on macos (#3243)

This commit is contained in:
HugoCasa
2024-02-19 09:58:12 +01:00
committed by GitHub
parent f8d5918b9c
commit 987a764476
3 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -76,7 +76,7 @@ pub async fn shutdown_signal(
) -> anyhow::Result<()> {
use std::io;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
async fn terminate() -> io::Result<()> {
use tokio::signal::unix::SignalKind;
tokio::signal::unix::signal(SignalKind::terminate())?
@@ -86,7 +86,7 @@ pub async fn shutdown_signal(
Ok(())
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
tokio::select! {
_ = terminate() => {},
_ = tokio::signal::ctrl_c() => {},
@@ -95,7 +95,7 @@ pub async fn shutdown_signal(
},
}
#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
tokio::select! {
_ = tokio::signal::ctrl_c() => {},
_ = rx.recv() => {
+8 -8
View File
@@ -1,9 +1,9 @@
use async_recursion::async_recursion;
use itertools::Itertools;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
use nix::sys::signal::{self, Signal};
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
use nix::unistd::Pid;
use regex::Regex;
@@ -27,7 +27,7 @@ use windmill_common::{
use anyhow::Result;
use windmill_queue::CanceledBy;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
use std::os::unix::process::ExitStatusExt;
use std::{
@@ -471,7 +471,7 @@ pub async fn handle_child(
let write_logs_delay = Duration::from_millis(500);
let pid = child.id();
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
if let Some(pid) = pid {
//set the highest oom priority
let mut file = File::create(format!("/proc/{pid}/oom_score_adj")).await?;
@@ -619,7 +619,7 @@ pub async fn handle_child(
if let Some(id) = child.id() {
if *MAX_WAIT_FOR_SIGINT > 0 {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
signal::kill(Pid::from_raw(id as i32), Signal::SIGINT).unwrap();
for _ in 0..*MAX_WAIT_FOR_SIGINT {
@@ -634,7 +634,7 @@ pub async fn handle_child(
}
}
if sigterm {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
signal::kill(Pid::from_raw(id as i32), Signal::SIGTERM).unwrap();
for _ in 0..*MAX_WAIT_FOR_SIGTERM {
@@ -772,7 +772,7 @@ pub async fn handle_child(
} else if let Some(code) = status.code() {
Err(error::Error::ExitStatus(code))
} else {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
return Err(error::Error::ExecutionErr(format!(
"process terminated by signal: {:#?}, stopped_signal: {:#?}, core_dumped: {}",
status.signal(),
@@ -780,7 +780,7 @@ pub async fn handle_child(
status.core_dumped()
)));
#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
return Err(error::Error::ExecutionErr(String::from(
"process terminated by signal",
)));
+1 -1
View File
@@ -51,7 +51,7 @@ use windmill_queue::{
use serde_json::{json, value::RawValue, Value};
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "macos"))]
use tokio::fs::symlink;
#[cfg(target_os = "windows")]