close program, when rpc port is used already
This commit is contained in:
parent
79fe17cf65
commit
77b2feef95
@ -64,7 +64,7 @@ pub fn json_rpc_server(
|
|||||||
config: PlayoutConfig,
|
config: PlayoutConfig,
|
||||||
play_control: PlayerControl,
|
play_control: PlayerControl,
|
||||||
playout_stat: PlayoutStatus,
|
playout_stat: PlayoutStatus,
|
||||||
proc_control: ProcessControl,
|
mut proc_control: ProcessControl,
|
||||||
) {
|
) {
|
||||||
let addr = config.rpc_server.address.clone();
|
let addr = config.rpc_server.address.clone();
|
||||||
let auth = config.rpc_server.authorization.clone();
|
let auth = config.rpc_server.authorization.clone();
|
||||||
@ -249,7 +249,7 @@ pub fn json_rpc_server(
|
|||||||
info!("Run JSON RPC server, listening on: <b><magenta>http://{addr}</></b>");
|
info!("Run JSON RPC server, listening on: <b><magenta>http://{addr}</></b>");
|
||||||
|
|
||||||
// build rpc server
|
// build rpc server
|
||||||
let server = ServerBuilder::new(io)
|
match ServerBuilder::new(io)
|
||||||
.cors(DomainsValidation::AllowOnly(vec![
|
.cors(DomainsValidation::AllowOnly(vec![
|
||||||
AccessControlAllowOrigin::Null,
|
AccessControlAllowOrigin::Null,
|
||||||
]))
|
]))
|
||||||
@ -269,9 +269,14 @@ pub fn json_rpc_server(
|
|||||||
})
|
})
|
||||||
.rest_api(RestApi::Secure)
|
.rest_api(RestApi::Secure)
|
||||||
.start_http(&addr.parse().unwrap())
|
.start_http(&addr.parse().unwrap())
|
||||||
.expect("Unable to start RPC server");
|
{
|
||||||
|
Ok(server) => {
|
||||||
*proc_control.rpc_handle.lock().unwrap() = Some(server.close_handle());
|
*proc_control.rpc_handle.lock().unwrap() = Some(server.close_handle());
|
||||||
|
server.wait();
|
||||||
server.wait();
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Unable to start RPC server: {e}");
|
||||||
|
proc_control.kill_all();
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
process::Child,
|
process::{exit, Child},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
atomic::{AtomicBool, AtomicUsize, Ordering},
|
||||||
Arc, Mutex,
|
Arc, Mutex,
|
||||||
@ -148,6 +148,8 @@ impl ProcessControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user