mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
mdns and nginx for main service
This commit is contained in:
committed by
Aiden McClelland
parent
9fb57d038a
commit
8dc3377bbd
@@ -1,5 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use patch_db::{LockType, PatchDbHandle};
|
||||
use rpc_toolkit::command;
|
||||
|
||||
use crate::context::RpcContext;
|
||||
@@ -8,10 +9,11 @@ use crate::sound::MARIO_DEATH;
|
||||
use crate::util::{display_none, Invoke};
|
||||
use crate::Error;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct Shutdown {
|
||||
zfs_pool: Arc<String>,
|
||||
restart: bool,
|
||||
db_handle: Arc<PatchDbHandle>,
|
||||
}
|
||||
impl Shutdown {
|
||||
/// BLOCKING
|
||||
@@ -64,22 +66,34 @@ impl Shutdown {
|
||||
|
||||
#[command(display(display_none))]
|
||||
pub async fn shutdown(#[context] ctx: RpcContext) -> Result<(), Error> {
|
||||
let mut db = ctx.db.handle();
|
||||
crate::db::DatabaseModel::new()
|
||||
.lock(&mut db, LockType::Write)
|
||||
.await;
|
||||
ctx.shutdown
|
||||
.send(Some(Shutdown {
|
||||
zfs_pool: ctx.zfs_pool_name.clone(),
|
||||
restart: false,
|
||||
db_handle: Arc::new(db),
|
||||
}))
|
||||
.map_err(|_| ())
|
||||
.expect("receiver dropped");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command(display(display_none))]
|
||||
pub async fn restart(#[context] ctx: RpcContext) -> Result<(), Error> {
|
||||
let mut db = ctx.db.handle();
|
||||
crate::db::DatabaseModel::new()
|
||||
.lock(&mut db, LockType::Write)
|
||||
.await;
|
||||
ctx.shutdown
|
||||
.send(Some(Shutdown {
|
||||
zfs_pool: ctx.zfs_pool_name.clone(),
|
||||
restart: true,
|
||||
db_handle: Arc::new(db),
|
||||
}))
|
||||
.map_err(|_| ())
|
||||
.expect("receiver dropped");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user