diff --git a/.gitignore b/.gitignore index b34bd16..40dd2ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ /target .idea -Dockerfile Cargo.lock -settings.json hagent_test.sock \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index a4c69c0..5b477a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,24 +1,12 @@ -[package] -name = "runner-rs" -version = "0.10.11" -edition = "2021" +[workspace] +resolver = "2" +members = [ + "noxis-rs", + "noxis-cli", +] [profile.dev] debug = true [profile.test] debug = false - -[dependencies] -anyhow = "1.0.93" -chrono = "0.4.38" -clap = { version = "4.5.21", features = ["derive"] } -env_logger = "0.11.3" -inotify = "0.10.2" -log = "0.4.22" -pcap = "2.2.0" -redis = "0.25.4" -serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.118" -sysinfo = "0.32.0" -tokio = { version = "1.38.0", features = ["full", "time"] } diff --git a/README.md b/README.md index b4fa045..449db98 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ -# runner-rs ( with amd64 and riscv64 support ) -![Logo](https://blog.desdelinux.net/wp-content/uploads/2023/07/rust-logo.png) -in-container integrating util to handle processes runtime - +# noxis-rs +![Logo](logo.png) +### In-container integrating util to handle processes runtime +( with amd64 and riscv64 support ) ## Depends on - `rustup (>=1.27.1)` - `gcc-riscv64-unknown-elf` - `build-essential` +- `gcc-riscv64-linux-gnu` +- `binutils-riscv64-linux-gnu` + ## Setting up Download and execute rustup.sh @@ -29,7 +32,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh cd runner-rs/ && rustup target add riscv64gc-unknown-linux-gnu && rustup target add x86_64-unknown-linux-gnu ~~~ > [!NOTE] -> Cargo is configured to build an app for amd64/linux defaultly. RISC-based compilation is optional. +> Cargo is configured to build an app for amd64/linux defaultly. RISCV-based compilation is optional. 3.1. Release build of app for amd64/linux diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..b8424ef Binary files /dev/null and b/logo.png differ diff --git a/noxis-cli/Cargo.toml b/noxis-cli/Cargo.toml new file mode 100644 index 0000000..5df0b28 --- /dev/null +++ b/noxis-cli/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "noxis-cli" +version = "0.1.5" +edition = "2021" + +[dependencies] +clap = { version = "4.5.22", features = ["derive"] } diff --git a/noxis-cli/src/cli.rs b/noxis-cli/src/cli.rs new file mode 100644 index 0000000..7235166 --- /dev/null +++ b/noxis-cli/src/cli.rs @@ -0,0 +1,134 @@ +use clap::{Parser, Subcommand}; + +#[derive(Debug, Parser)] +pub struct Cli { + #[command( + subcommand, + help = "status|start|stop|restart|", + )] + command : Commands, +} +#[derive(Debug, Subcommand)] +pub enum Commands { + #[command( + about = "To get info about current Noxis status", + )] + Status, + #[command( + about = "To start Noxis process", + )] + Start, + #[command( + about = "To stop Noxis process", + )] + Stop, + #[command( + about = "To restart Noxis process", + )] + Restart, + #[command( + about = "To get list of processes that are being monitoring", + )] + Processes, + // process command + #[command( + about = "To manage current process that is being monitoring", + )] + Process(ProcessCommand), + // config command = + #[command( + about = "To manage config settings", + )] + Config(ConfigCommand), +} + +#[derive(Debug, Parser)] +pub struct ConfigCommand { + #[command(subcommand)] + action : ConfigAction, +} + +#[derive(Debug, Subcommand)] +pub enum ConfigAction { + #[command( + about = "To change current Noxis configuration", + )] + Local(LocalConfig), + #[command( + about = "To change credentials of the remote config server", + )] + Remote, + #[command( + about = "To reset all config settings", + )] + Reset, +} + +#[derive(Debug, Parser)] +pub struct LocalConfig { + // flag + #[arg( + long = "json", + action, + help = "to read following input as JSON", + )] + type_of_entry : bool, + // value + #[arg( + help = "path to config file or config String (with --json flag)", + )] + config : String, +} + +#[derive(Debug, Parser)] +pub struct ProcessCommand { + #[arg( + help = "name of needed process", + )] + process : String, + #[command( + subcommand, + help = "To get current process's status", + )] + action : ProcessAction, +} + +#[derive(Debug, Subcommand)] +enum ProcessAction { + #[command( + about = "To get info about current process status", + )] + Status, + #[command( + about = "To start current process", + )] + Start, + #[command( + about = "To stop current process", + )] + Stop, + #[command( + about = "To freeze (hybernaze) current process", + )] + Freeze, + #[command( + about = "To unfreeze (unhybernaze) current process", + )] + Unfreeze, + #[command( + about = "To restart current process", + )] + Restart, + #[command( + about = "To get info about current process's dependencies", + )] + Deps, + #[command( + about = "To get info about current process's files-dependencies", + )] + Files, + #[command( + about = "To get info about current process's services-dependencies", + )] + Services, +} \ No newline at end of file diff --git a/noxis-cli/src/main.rs b/noxis-cli/src/main.rs new file mode 100644 index 0000000..023c977 --- /dev/null +++ b/noxis-cli/src/main.rs @@ -0,0 +1,11 @@ +mod cli; + +use clap::Parser; +use cli::Cli; + +fn main() -> Result<(), std::io::Error>{ + let cli = Cli::parse(); + dbg!(&cli); + println!("{:?}", cli); + Ok(()) +} diff --git a/noxis-rs/Cargo.toml b/noxis-rs/Cargo.toml new file mode 100644 index 0000000..ed2f9c3 --- /dev/null +++ b/noxis-rs/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "noxis-rs" +version = "0.10.11" +edition = "2021" + +[dependencies] +anyhow = "1.0.93" +chrono = "0.4.38" +clap = { version = "4.5.21", features = ["derive"] } +env_logger = "0.11.3" +inotify = "0.10.2" +log = "0.4.22" +pcap = "2.2.0" +redis = "0.25.4" +serde = { version = "1.0.203", features = ["derive"] } +serde_json = "1.0.118" +sysinfo = "0.32.0" +tokio = { version = "1.38.0", features = ["full", "time"] } diff --git a/Dockerfile b/noxis-rs/Dockerfile similarity index 100% rename from Dockerfile rename to noxis-rs/Dockerfile diff --git a/settings.json b/noxis-rs/settings.json similarity index 100% rename from settings.json rename to noxis-rs/settings.json diff --git a/src/lib.rs b/noxis-rs/src/lib.rs similarity index 100% rename from src/lib.rs rename to noxis-rs/src/lib.rs diff --git a/src/main.rs b/noxis-rs/src/main.rs similarity index 100% rename from src/main.rs rename to noxis-rs/src/main.rs diff --git a/src/options.rs b/noxis-rs/src/options.rs similarity index 100% rename from src/options.rs rename to noxis-rs/src/options.rs diff --git a/src/options/config.rs b/noxis-rs/src/options/config.rs similarity index 100% rename from src/options/config.rs rename to noxis-rs/src/options/config.rs diff --git a/src/options/logger.rs b/noxis-rs/src/options/logger.rs similarity index 100% rename from src/options/logger.rs rename to noxis-rs/src/options/logger.rs diff --git a/src/options/preboot.rs b/noxis-rs/src/options/preboot.rs similarity index 100% rename from src/options/preboot.rs rename to noxis-rs/src/options/preboot.rs diff --git a/src/options/signals.rs b/noxis-rs/src/options/signals.rs similarity index 100% rename from src/options/signals.rs rename to noxis-rs/src/options/signals.rs diff --git a/src/options/structs.rs b/noxis-rs/src/options/structs.rs similarity index 100% rename from src/options/structs.rs rename to noxis-rs/src/options/structs.rs diff --git a/src/utils.rs b/noxis-rs/src/utils.rs similarity index 100% rename from src/utils.rs rename to noxis-rs/src/utils.rs diff --git a/src/utils/files.rs b/noxis-rs/src/utils/files.rs similarity index 95% rename from src/utils/files.rs rename to noxis-rs/src/utils/files.rs index 515aaa1..28346c2 100644 --- a/src/utils/files.rs +++ b/noxis-rs/src/utils/files.rs @@ -98,7 +98,10 @@ pub async fn file_handler( // * watcher recreation after dealing with file recreation mechanism in text editors let mutex = notify.borrow_mut(); - *mutex = create_watcher(&file.filename, &file.src).await.unwrap(); + // *mutex = create_watcher(&file.filename, &file.src).await.unwrap(); + if let Ok(watcher) = create_watcher(&file.filename, &file.src).await { + *mutex = watcher; + } } match file.triggers.on_change.as_str() { "stop" => { diff --git a/src/utils/hagent.rs b/noxis-rs/src/utils/hagent.rs similarity index 100% rename from src/utils/hagent.rs rename to noxis-rs/src/utils/hagent.rs diff --git a/src/utils/metrics.rs b/noxis-rs/src/utils/metrics.rs similarity index 100% rename from src/utils/metrics.rs rename to noxis-rs/src/utils/metrics.rs diff --git a/src/utils/prcs.rs b/noxis-rs/src/utils/prcs.rs similarity index 100% rename from src/utils/prcs.rs rename to noxis-rs/src/utils/prcs.rs diff --git a/src/utils/services.rs b/noxis-rs/src/utils/services.rs similarity index 100% rename from src/utils/services.rs rename to noxis-rs/src/utils/services.rs diff --git a/temp-process b/noxis-rs/temp-process similarity index 100% rename from temp-process rename to noxis-rs/temp-process diff --git a/tests/examples/dep-file b/noxis-rs/tests/examples/dep-file similarity index 100% rename from tests/examples/dep-file rename to noxis-rs/tests/examples/dep-file diff --git a/tests/examples/freeze-check b/noxis-rs/tests/examples/freeze-check similarity index 100% rename from tests/examples/freeze-check rename to noxis-rs/tests/examples/freeze-check diff --git a/tests/examples/invalid_config.json b/noxis-rs/tests/examples/invalid_config.json similarity index 100% rename from tests/examples/invalid_config.json rename to noxis-rs/tests/examples/invalid_config.json diff --git a/tests/examples/none.json b/noxis-rs/tests/examples/none.json similarity index 100% rename from tests/examples/none.json rename to noxis-rs/tests/examples/none.json diff --git a/tests/examples/pidof-prc b/noxis-rs/tests/examples/pidof-prc similarity index 100% rename from tests/examples/pidof-prc rename to noxis-rs/tests/examples/pidof-prc diff --git a/tests/examples/restart-prc b/noxis-rs/tests/examples/restart-prc similarity index 100% rename from tests/examples/restart-prc rename to noxis-rs/tests/examples/restart-prc diff --git a/tests/examples/run.sh b/noxis-rs/tests/examples/run.sh similarity index 100% rename from tests/examples/run.sh rename to noxis-rs/tests/examples/run.sh diff --git a/tests/examples/save-conf.json b/noxis-rs/tests/examples/save-conf.json similarity index 100% rename from tests/examples/save-conf.json rename to noxis-rs/tests/examples/save-conf.json diff --git a/tests/examples/settings.json b/noxis-rs/tests/examples/settings.json similarity index 100% rename from tests/examples/settings.json rename to noxis-rs/tests/examples/settings.json diff --git a/tests/examples/tmp-prc b/noxis-rs/tests/examples/tmp-prc similarity index 100% rename from tests/examples/tmp-prc rename to noxis-rs/tests/examples/tmp-prc diff --git a/tests/start_stop.rs b/noxis-rs/tests/start_stop.rs similarity index 100% rename from tests/start_stop.rs rename to noxis-rs/tests/start_stop.rs