Skip to content

Commit

Permalink
Refactor horust to its own crate
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoPonzi committed Nov 1, 2024
1 parent 2562466 commit f550d7a
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 51 deletions.
47 changes: 1 addition & 46 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,2 @@
[package]
name = "horust"
version = "0.1.8"
authors = ["Federico Ponzi <[email protected]>"]
description = "A complete supervisor and init system, designed for running in containers."
edition = "2021"
license = "MIT"
repository = "https://github.com/FedericoPonzi/horust"
homepage = "https://github.com/FedericoPonzi/horust"
readme = "README.md"
keywords = ["init", "container", "supervisor"]
categories = ["command-line-utilities"]
include = ["src/**/*", "Cargo.*", "LICENSE.txt", "README.md", "/example_services/**/*"]

[dependencies]
clap = { version = "~4.5", features = ["derive"] }
crossbeam = "~0.8"
env_logger = "~0.11"
humantime-serde = "~1.1"
libc = "~0.2"
log = "~0.4"
nix = { version = "~0.29", features = ["process", "user", "signal", "fs"] }
reqwest = { version = "~0.12", features = ["blocking", "json"], optional = true, default-features = false }
serde = { version = "~1.0", features = ["derive"] }
shlex = "~1.3"
toml = "~0.8"
maplit = "~1.0"
shellexpand = "~3.1"
anyhow = "~1.0"
thiserror = "~1.0"
bytefmt = "0.1.7"

[features]
default = ["http-healthcheck"]
http-healthcheck = ["reqwest"]

[dev-dependencies]
assert_cmd = "~2.0"
predicates = "~3.1"
tempdir = "~0.3"
rand = "~0.8"

[profile.release]
strip = "symbols"

[workspace]
members = ["horustctl", "commands"]
members = ["commands", "horust", "horustctl"]
1 change: 0 additions & 1 deletion commands/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
mod proto;

use anyhow::{bail, Context, Result};
use proto::tutorial::*;
use std::path::{Path, PathBuf};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{UnixListener, UnixStream};
Expand Down
2 changes: 1 addition & 1 deletion commands/src/proto/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod tutorial;

12 changes: 11 additions & 1 deletion commands/src/proto/tutorial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ pub mod person {
#[prost(enumeration = "PhoneType", tag = "2")]
pub r#type: i32,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum PhoneType {
Mobile = 0,
Expand Down
44 changes: 44 additions & 0 deletions horust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "horust"
version = "0.1.8"
authors = ["Federico Ponzi <[email protected]>"]
description = "A complete supervisor and init system, designed for running in containers."
edition = "2021"
license = "MIT"
repository = "https://github.com/FedericoPonzi/horust"
homepage = "https://github.com/FedericoPonzi/horust"
readme = "README.md"
keywords = ["init", "container", "supervisor"]
categories = ["command-line-utilities"]
include = ["src/**/*", "Cargo.*", "LICENSE.txt", "README.md", "/example_services/**/*"]

[dependencies]
clap = { version = "~4.5", features = ["derive"] }
crossbeam = "~0.8"
env_logger = "~0.11"
humantime-serde = "~1.1"
libc = "~0.2"
log = "~0.4"
nix = { version = "~0.29", features = ["process", "user", "signal", "fs"] }
reqwest = { version = "~0.12", features = ["blocking", "json"], optional = true, default-features = false }
serde = { version = "~1.0", features = ["derive"] }
shlex = "~1.3"
toml = "~0.8"
maplit = "~1.0"
shellexpand = "~3.1"
anyhow = "~1.0"
thiserror = "~1.0"
bytefmt = "0.1.7"

[features]
default = ["http-healthcheck"]
http-healthcheck = ["reqwest"]

[dev-dependencies]
assert_cmd = "~2.0"
predicates = "~3.1"
tempdir = "~0.3"
rand = "~0.8"

[profile.release]
strip = "symbols"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{env, os::fd::RawFd};
use crate::horust::error::{ValidationError, ValidationErrors};

pub fn get_sample_service() -> &'static str {
include_str!("../../../example_services/sample_service.toml")
include_str!("../../../../example_services/sample_service.toml")
}

pub type ServiceName = String;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod tests {
fn should_deserialize() {
// TODO: this shouldn't be an integration test, but rather a unit test.
let base = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let services_path = base.join("example_services");
let services_path = base.join("../../example_services");
let services = list_files(&services_path).unwrap().len();
let horust = Horust::from_services_dirs(&[services_path]).unwrap();
assert_eq!(horust.get_services().len(), services);
Expand Down
File renamed without changes.

0 comments on commit f550d7a

Please sign in to comment.