stop decoder with SIGTERM signal, instead of kill on non windows systems
This commit is contained in:
parent
d1716acfc5
commit
d2c72d56fe
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -1191,6 +1191,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"shlex",
|
||||
"signal-child",
|
||||
"simplelog",
|
||||
"time 0.3.23",
|
||||
"walkdir",
|
||||
@ -2817,6 +2818,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||
|
||||
[[package]]
|
||||
name = "signal-child"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2a4eed4c5ae38438470ab8e0108bb751012f786f44ff585cfd837c9a5fe426f"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.1"
|
||||
|
@ -159,15 +159,11 @@ pub fn player(
|
||||
thread::spawn(move || stderr_reader(dec_err, Decoder, dec_p_ctl));
|
||||
|
||||
loop {
|
||||
// when server is running, read from channel
|
||||
// when server is running, read from it
|
||||
if proc_control.server_is_running.load(Ordering::SeqCst) {
|
||||
if !live_on {
|
||||
info!("Switch from {} to live ingest", config.processing.mode);
|
||||
|
||||
if let Err(e) = enc_writer.flush() {
|
||||
error!("Encoder error: {e}")
|
||||
}
|
||||
|
||||
if let Err(e) = proc_control.stop(Decoder) {
|
||||
error!("{e}")
|
||||
}
|
||||
@ -188,11 +184,8 @@ pub fn player(
|
||||
if live_on {
|
||||
info!("Switch from live ingest to {}", config.processing.mode);
|
||||
|
||||
if let Err(e) = enc_writer.flush() {
|
||||
error!("Encoder error: {e}")
|
||||
}
|
||||
|
||||
live_on = false;
|
||||
break;
|
||||
}
|
||||
|
||||
let dec_bytes_len = match dec_reader.read(&mut buffer[..]) {
|
||||
|
@ -32,3 +32,6 @@ features = ["shlobj", "std", "winerror"]
|
||||
|
||||
[target.x86_64-unknown-linux-musl.dependencies]
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
|
||||
[target.'cfg(not(target_arch = "windows"))'.dependencies]
|
||||
signal-child = "1"
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
fmt,
|
||||
env, fmt,
|
||||
process::Child,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
||||
@ -7,6 +7,9 @@ use std::{
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(not(windows))]
|
||||
use signal_child::Signalable;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use simplelog::*;
|
||||
|
||||
@ -71,9 +74,13 @@ impl ProcessControl {
|
||||
match unit {
|
||||
Decoder => {
|
||||
if let Some(proc) = self.decoder_term.lock().unwrap().as_mut() {
|
||||
if let Err(e) = proc.kill() {
|
||||
if env::consts::OS != "windows" {
|
||||
if let Err(e) = proc.term() {
|
||||
return Err(format!("Decoder {e:?}"));
|
||||
}
|
||||
} else if let Err(e) = proc.kill() {
|
||||
return Err(format!("Decoder {e:?}"));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Encoder => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user