mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
exclude non linux/macos targets from compiling ShutdownSignal
This commit is contained in:
parent
68ba2b4e1e
commit
ea2c690189
@ -69,13 +69,18 @@ fn main() -> io::Result<()> {
|
|||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
{
|
{
|
||||||
for signal in &settings.shutdown_signals {
|
for signal in &settings.shutdown_signals {
|
||||||
let _ = signal_hook::flag::register(
|
let _ = signal_hook::flag::register(signal.to_signal(), Arc::clone(&shutdown_signal));
|
||||||
*signal as core::ffi::c_int,
|
|
||||||
Arc::clone(&shutdown_signal),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||||
|
if !settings.shutdown_signals.is_empty() {
|
||||||
|
tracing::warn!(
|
||||||
|
"Server configuration contains shutdown signals, but your platform does not support \
|
||||||
|
them"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Determine folder to save server data in
|
// Determine folder to save server data in
|
||||||
let server_data_dir = {
|
let server_data_dir = {
|
||||||
let mut path = common_base::userdata_dir_workspace!();
|
let mut path = common_base::userdata_dir_workspace!();
|
||||||
|
@ -7,12 +7,22 @@ use std::{
|
|||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||||
#[repr(i32)]
|
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
pub enum ShutdownSignal {
|
pub enum ShutdownSignal {
|
||||||
SIGUSR1 = signal_hook::consts::SIGUSR1,
|
SIGUSR1,
|
||||||
SIGUSR2 = signal_hook::consts::SIGUSR2,
|
SIGUSR2,
|
||||||
SIGTERM = signal_hook::consts::SIGTERM,
|
SIGTERM,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ShutdownSignal {
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
|
pub fn to_signal(self) -> core::ffi::c_int {
|
||||||
|
match self {
|
||||||
|
Self::SIGUSR1 => signal_hook::consts::SIGUSR1,
|
||||||
|
Self::SIGUSR2 => signal_hook::consts::SIGUSR2,
|
||||||
|
Self::SIGTERM => signal_hook::consts::SIGTERM,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
@ -34,7 +44,11 @@ impl Default for Settings {
|
|||||||
update_shutdown_message: "The server is restarting for an update".to_owned(),
|
update_shutdown_message: "The server is restarting for an update".to_owned(),
|
||||||
web_address: SocketAddr::from((Ipv4Addr::LOCALHOST, 14005)),
|
web_address: SocketAddr::from((Ipv4Addr::LOCALHOST, 14005)),
|
||||||
web_chat_secret: None,
|
web_chat_secret: None,
|
||||||
shutdown_signals: vec![ShutdownSignal::SIGUSR1],
|
shutdown_signals: if cfg!(any(target_os = "linux", target_os = "macos")) {
|
||||||
|
vec![ShutdownSignal::SIGUSR1]
|
||||||
|
} else {
|
||||||
|
Vec::new()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user