mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-10 00:20:29 -04:00
main: Wait on ctrl-c
This commit is contained in:
parent
7e262a1d96
commit
cdf4297f9f
2 changed files with 9 additions and 5 deletions
|
@ -8,7 +8,7 @@ strip="symbols"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
tokio = { version = "1", features = ["fs", "process", "io-std", "rt-multi-thread", "macros"] }
|
||||
tokio = { version = "1", features = ["fs", "io-std", "macros", "process", "rt-multi-thread", "signal"] }
|
||||
tracing = { version = "0.1", default-features = false }
|
||||
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }
|
||||
zbus = { version = "4", features = ["tokio"] }
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -23,11 +23,12 @@
|
|||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{Error, Result};
|
||||
use tokio::signal::unix::{signal, SignalKind};
|
||||
use tracing_subscriber;
|
||||
use zbus::ConnectionBuilder;
|
||||
|
||||
pub mod manager;
|
||||
mod manager;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
|
@ -36,6 +37,8 @@ async fn main() -> Result<()> {
|
|||
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let mut sigterm = signal(SignalKind::terminate())?;
|
||||
|
||||
let manager = manager::SMManager::new()?;
|
||||
|
||||
let _system_connection = ConnectionBuilder::system()?
|
||||
|
@ -44,7 +47,8 @@ async fn main() -> Result<()> {
|
|||
.build()
|
||||
.await?;
|
||||
|
||||
loop {
|
||||
std::future::pending::<()>().await;
|
||||
tokio::select! {
|
||||
e = sigterm.recv() => e.ok_or(Error::msg("SIGTERM pipe broke")),
|
||||
e = tokio::signal::ctrl_c() => Ok(e?),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue