-
Notifications
You must be signed in to change notification settings - Fork 19
Recommended Way to Shutdown Varlink Server? #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was thinking about passing in an Would you be open to a PR for that? |
just return |
rust/examples/more/src/main.rs Lines 163 to 166 in 81463ba
|
Factor out the `varlink::listen` parameters into a `varlink::ListenConfig` struct, so we can use ..Default::default(). Add an `stop_listening: Option<Arc<AtomicBool>>` to the `varlink::ListenConfig` struct, which can be set remotely to break the `varlink::listen` loop. Stop the running server after 10 seconds ```rust use std::{thread, time}; use std::sync::atomic::Ordering; let stop_listening = Arc::new(std::sync::atomic::AtomicBool::new(false)); let child = { let stop_running = stop_listening.clone(); thread::spawn(move || { thread::sleep(time::Duration::from_secs(10)); // Stop the running server after 10 seconds stop_listening.store(true, Ordering::Relaxed); }) }; varlink::listen( service, &address, &varlink::ListenConfig { idle_timeout: timeout, stop_listening: Some(stop_listening), ..Default::default() }, )?; child.join().expect("Error joining thread"); ``` Obsoletes varlink#26 Addresses varlink#25
What do you think about PR #27 ?? |
Factor out the `varlink::listen` parameters into a `varlink::ListenConfig` struct, so we can use ..Default::default(). Add an `stop_listening: Option<Arc<AtomicBool>>` to the `varlink::ListenConfig` struct, which can be set remotely to break the `varlink::listen` loop. Stop the running server after 10 seconds ```rust use std::{thread, time}; use std::sync::atomic::Ordering; let stop_listening = Arc::new(std::sync::atomic::AtomicBool::new(false)); let child = { let stop_running = stop_listening.clone(); thread::spawn(move || { thread::sleep(time::Duration::from_secs(10)); // Stop the running server after 10 seconds stop_listening.store(true, Ordering::Relaxed); }) }; varlink::listen( service, &address, &varlink::ListenConfig { idle_timeout: timeout, stop_listening: Some(stop_listening), ..Default::default() }, )?; child.join().expect("Error joining thread"); ``` Obsoletes varlink#26 Addresses varlink#25
Factor out the `varlink::listen` parameters into a `varlink::ListenConfig` struct, so we can use ..Default::default(). Add an `stop_listening: Option<Arc<AtomicBool>>` to the `varlink::ListenConfig` struct, which can be set remotely to break the `varlink::listen` loop. Stop the running server after 10 seconds ```rust use std::{thread, time}; use std::sync::atomic::Ordering; let stop_listening = Arc::new(std::sync::atomic::AtomicBool::new(false)); let child = { let stop_running = stop_listening.clone(); thread::spawn(move || { thread::sleep(time::Duration::from_secs(10)); // Stop the running server after 10 seconds stop_listening.store(true, Ordering::Relaxed); }) }; varlink::listen( service, &address, &varlink::ListenConfig { idle_timeout: timeout, stop_listening: Some(stop_listening), ..Default::default() }, )?; child.join().expect("Error joining thread"); ``` Obsoletes varlink#26 Addresses varlink#25
Factor out the `varlink::listen` parameters into a `varlink::ListenConfig` struct, so we can use ..Default::default(). Add an `stop_listening: Option<Arc<AtomicBool>>` to the `varlink::ListenConfig` struct, which can be set remotely to break the `varlink::listen` loop. Stop the running server after 10 seconds ```rust use std::{thread, time}; use std::sync::atomic::Ordering; let stop_listening = Arc::new(std::sync::atomic::AtomicBool::new(false)); let child = { let stop_running = stop_listening.clone(); thread::spawn(move || { thread::sleep(time::Duration::from_secs(10)); // Stop the running server after 10 seconds stop_listening.store(true, Ordering::Relaxed); }) }; varlink::listen( service, &address, &varlink::ListenConfig { idle_timeout: timeout, stop_listening: Some(stop_listening), ..Default::default() }, )?; child.join().expect("Error joining thread"); ``` Obsoletes varlink#26 Addresses varlink#25
Factor out the `varlink::listen` parameters into a `varlink::ListenConfig` struct, so we can use ..Default::default(). Add an `stop_listening: Option<Arc<AtomicBool>>` to the `varlink::ListenConfig` struct, which can be set remotely to break the `varlink::listen` loop. Stop the running server after 10 seconds ```rust use std::{thread, time}; use std::sync::atomic::Ordering; let stop_listening = Arc::new(std::sync::atomic::AtomicBool::new(false)); let child = { let stop_running = stop_listening.clone(); thread::spawn(move || { thread::sleep(time::Duration::from_secs(10)); // Stop the running server after 10 seconds stop_listening.store(true, Ordering::Relaxed); }) }; varlink::listen( service, &address, &varlink::ListenConfig { idle_timeout: timeout, stop_listening: Some(stop_listening), ..Default::default() }, )?; child.join().expect("Error joining thread"); ``` Obsoletes #26 Addresses #25
The above PR was merged 4 years ago, why is this issue still open? |
Is there a recommended way to shutdown the Varlink server when it is started with
varlink::listen()
?I'm sure I could find a way to do it if I implemented the server myself, I was just making sure that there wasn't already a good way to do it.
Specifically I am looking to be able to shutdown the server in response to an RPC call, if that changes anything.
The text was updated successfully, but these errors were encountered: