This commit is contained in:
@@ -44,5 +44,6 @@ pub fn new(name: &str, cmd: &str) -> Result<()> {
|
||||
pub fn kill(name: &str) -> Result<()> {
|
||||
let cmd = format!("screen -S {} -X quit", name);
|
||||
run_command(&cmd)?;
|
||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||
Ok(())
|
||||
}
|
@@ -5,6 +5,7 @@
|
||||
use crate::rhai::error::ToRhaiError;
|
||||
use crate::zinit_client as client;
|
||||
use rhai::{Array, Dynamic, Engine, EvalAltResult, Map};
|
||||
use std::path::Path;
|
||||
use serde_json::{json, Value};
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
@@ -55,6 +56,12 @@ fn get_runtime() -> Result<Runtime, Box<EvalAltResult>> {
|
||||
///
|
||||
/// Lists all services managed by Zinit.
|
||||
pub fn zinit_list(socket_path: &str) -> Result<Map, Box<EvalAltResult>> {
|
||||
if !Path::new(socket_path).exists() {
|
||||
return Err(Box::new(EvalAltResult::ErrorRuntime(
|
||||
format!("Zinit socket not found at '{}'", socket_path).into(),
|
||||
rhai::Position::NONE,
|
||||
)));
|
||||
}
|
||||
let rt = get_runtime()?;
|
||||
|
||||
let result = rt.block_on(async { client::list(socket_path).await });
|
||||
|
Reference in New Issue
Block a user