aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-11-13 19:59:20 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-11-13 19:59:20 +0100
commitc771f36ae4b91670fc7142267014b0ce52d85a32 (patch)
tree130a3d7bafdd98a8d04a6b0ac7c55204abd508da
parent9d1031fa268faf8eaa9871250f2c1e8126d85a1f (diff)
remove anyhow: can be replaced by io::Result
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs16
2 files changed, 9 insertions, 8 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 6794aab..eaf5ee5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-anyhow = "1.0.68"
humantime = "2.1.0"
sys-mount = { version = "2.0.2", default-features = false }
termcolor = "1.1.3"
diff --git a/src/main.rs b/src/main.rs
index 31a035f..50b7685 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,10 @@
use std::fs::{self, DirEntry, File};
-use std::io::{BufRead, BufReader, Seek, Write};
+use std::io::{BufRead, BufReader, Result, Seek, Write};
use std::path::Path;
use std::process::{self, ChildStderr, ChildStdout, Command, Stdio};
use std::thread;
use std::time::{Duration, SystemTime};
-use anyhow::bail;
use sys_mount::{Mount, Unmount, UnmountDrop, UnmountFlags};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
@@ -60,14 +59,17 @@ macro_rules! halt {
};
}
-fn start() -> anyhow::Result<()> {
+fn start() -> Result<()> {
log!(Color::Yellow, "Starting rustkrazy");
for service in fs::read_dir("/bin")? {
let service = service?;
let service_name = match service.file_name().into_string() {
Ok(v) => v,
- Err(_) => bail!("[ ERROR ] invalid unicode in file name"),
+ Err(_) => {
+ log!(Color::Red, "[ ERROR ] invalid unicode in file name");
+ continue;
+ }
};
if service_name == "init" {
@@ -83,7 +85,7 @@ fn start() -> anyhow::Result<()> {
Ok(())
}
-fn supervise(service: DirEntry, service_name: String) -> anyhow::Result<()> {
+fn supervise(service: DirEntry, service_name: String) -> Result<()> {
loop {
let mut cmd = Command::new(service.path());
cmd.stdout(Stdio::piped());
@@ -135,7 +137,7 @@ fn supervise(service: DirEntry, service_name: String) -> anyhow::Result<()> {
}
}
-fn log_out(pipe: ChildStdout, service_name: String) -> anyhow::Result<()> {
+fn log_out(pipe: ChildStdout, service_name: String) -> Result<()> {
let mut file = File::create(Path::new("/tmp").join(service_name.clone() + ".log"))?;
let mut r = BufReader::new(pipe);
@@ -159,7 +161,7 @@ fn log_out(pipe: ChildStdout, service_name: String) -> anyhow::Result<()> {
}
}
-fn log_err(pipe: ChildStderr, service_name: String) -> anyhow::Result<()> {
+fn log_err(pipe: ChildStderr, service_name: String) -> Result<()> {
let mut file = File::create(Path::new("/tmp").join(service_name.clone() + ".err"))?;
let mut r = BufReader::new(pipe);