mdns and nginx for main service

This commit is contained in:
Aiden McClelland
2021-09-14 16:45:39 -06:00
committed by Aiden McClelland
parent 9fb57d038a
commit 8dc3377bbd
9 changed files with 151 additions and 23 deletions

View File

@@ -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(())
}