From ae82b810c8d6a48f3803896780f1ecf617cb7f1b Mon Sep 17 00:00:00 2001 From: overweight Date: Mon, 11 Dec 2023 10:31:31 +0800 Subject: [PATCH 1/2] feature: next-generation sysmaster with tokio and zbus, need 1.64 rustc --- .pre-commit-config.yaml | 5 +- Cargo.toml | 2 +- ci/00-pre.sh | 1 - ci/codespell_ignore_words | 1 + ng/Cargo.lock | 1387 +++++++++++++++++++++++++++++++++++++ ng/Cargo.toml | 20 + ng/src/bins/syscontrol.rs | 23 + ng/src/bins/sysmaster.rs | 21 + ng/src/jobs/mod.rs | 17 + ng/src/lib.rs | 3 + ng/src/manager/bus.rs | 46 ++ ng/src/manager/config.rs | 12 + ng/src/manager/mod.rs | 50 ++ ng/src/units/mod.rs | 107 +++ ng/src/units/service.rs | 64 ++ ng/src/units/socket.rs | 27 + 16 files changed, 1781 insertions(+), 5 deletions(-) create mode 100644 ng/Cargo.lock create mode 100644 ng/Cargo.toml create mode 100644 ng/src/bins/syscontrol.rs create mode 100644 ng/src/bins/sysmaster.rs create mode 100644 ng/src/jobs/mod.rs create mode 100644 ng/src/lib.rs create mode 100644 ng/src/manager/bus.rs create mode 100644 ng/src/manager/config.rs create mode 100644 ng/src/manager/mod.rs create mode 100644 ng/src/units/mod.rs create mode 100644 ng/src/units/service.rs create mode 100644 ng/src/units/socket.rs diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b9739e18..8dd78af2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: rev: v4.4.0 hooks: - id: check-added-large-files - args: ['--maxkb=100'] + args: ["--maxkb=100"] - id: check-symlinks - id: check-toml - id: end-of-file-fixer @@ -19,7 +19,7 @@ repos: - id: codespell name: codespell description: Checks for common misspellings in text files. - entry: bash -c 'cargo clean;codespell -I ci/codespell_ignore_words -x ci/codespell_ignore_words -S *.rules -S ./vendor* -S ./target*' + entry: bash -c 'cargo clean;codespell -I ci/codespell_ignore_words -x ci/codespell_ignore_words -S *.rules -S vendor* -S target*' language: system pass_filenames: false verbose: true @@ -87,7 +87,6 @@ repos: pass_filenames: false files: \.(rs|toml)$ verbose: false - # - id: cargo-deny # name: cargo deny check # description: Check cargo depencencies diff --git a/Cargo.toml b/Cargo.toml index 7137f026..63fa7269 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,7 +141,7 @@ members = [ "libs/unit_parser", "libs/hwdb", ] -exclude = ["docs", "ci", "factory", "tools", "next"] +exclude = ["docs", "ci", "factory", "tools", "next", "ng"] # fix https://github.com/mdaffin/loopdev/issues/65 [patch.crates-io.loopdev] diff --git a/ci/00-pre.sh b/ci/00-pre.sh index 7a42630b..cc40b307 100755 --- a/ci/00-pre.sh +++ b/ci/00-pre.sh @@ -37,7 +37,6 @@ rustup default $rust_vendor # Define the crate names to test crate_names=("https://github.com/rust-lang/crates.io-index" \ "https://mirrors.ustc.edu.cn/crates.io-index" \ - "https://rsproxy.cn/crates.io-index" \ "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git" \ "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index") diff --git a/ci/codespell_ignore_words b/ci/codespell_ignore_words index 6c661b8d..bdc9c1b1 100644 --- a/ci/codespell_ignore_words +++ b/ci/codespell_ignore_words @@ -5,3 +5,4 @@ renderD Cruzer ser ether +ot diff --git a/ng/Cargo.lock b/ng/Cargo.lock new file mode 100644 index 00000000..911da2de --- /dev/null +++ b/ng/Cargo.lock @@ -0,0 +1,1387 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "async-broadcast" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" +dependencies = [ + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" +dependencies = [ + "async-lock 3.2.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.1.0", + "parking", + "polling 3.3.1", + "rustix 0.38.28", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +dependencies = [ + "event-listener 4.0.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" +dependencies = [ + "async-io 1.13.0", + "async-lock 2.8.0", + "async-signal", + "blocking", + "cfg-if", + "event-listener 3.1.0", + "futures-lite 1.13.0", + "rustix 0.38.28", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-recursion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "async-signal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +dependencies = [ + "async-io 2.2.1", + "async-lock 2.8.0", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 0.38.28", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-task" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" + +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel", + "async-lock 3.2.0", + "async-task", + "fastrand 2.0.1", + "futures-io", + "futures-lite 2.1.0", + "piper", + "tracing", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "concurrent-queue" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "cpufeatures" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "enumflags2" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" + +[[package]] +name = "futures-util" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +dependencies = [ + "futures-core", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.28", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "serde_repr" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sysmaster-ng" +version = "0.1.0" +dependencies = [ + "async-trait", + "log", + "once_cell", + "tokio", + "zbus", +] + +[[package]] +name = "tempfile" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +dependencies = [ + "cfg-if", + "fastrand 2.0.1", + "redox_syscall", + "rustix 0.38.28", + "windows-sys 0.48.0", +] + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tokio" +version = "1.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.5.5", + "tokio-macros", + "tracing", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "uds_windows" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "xdg-home" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +dependencies = [ + "nix", + "winapi", +] + +[[package]] +name = "zbus" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +dependencies = [ + "async-broadcast", + "async-process", + "async-recursion", + "async-trait", + "byteorder", + "derivative", + "enumflags2", + "event-listener 2.5.3", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix", + "once_cell", + "ordered-stream", + "rand", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tokio", + "tracing", + "uds_windows", + "winapi", + "xdg-home", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb80bb776dbda6e23d705cf0123c3b95df99c4ebeaec6c2599d4a5419902b4a9" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + +[[package]] +name = "zvariant" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44b291bee0d960c53170780af148dca5fa260a63cdd24f1962fa82e03e53338c" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] diff --git a/ng/Cargo.toml b/ng/Cargo.toml new file mode 100644 index 00000000..a320b7d6 --- /dev/null +++ b/ng/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "sysmaster-ng" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "sysmaster" +path = "src/bins/sysmaster.rs" + +[[bin]] +name = "syscontrol" +path = "src/bins/syscontrol.rs" + +[dependencies] +async-trait = "0.1.74" +log = "0.4.20" +once_cell = "1.19.0" +tokio = { version = "1.35.0", features = ["full"] } +zbus = { version = "3.14.1", default-features = false, features = ["tokio"] } diff --git a/ng/src/bins/syscontrol.rs b/ng/src/bins/syscontrol.rs new file mode 100644 index 00000000..8610fc00 --- /dev/null +++ b/ng/src/bins/syscontrol.rs @@ -0,0 +1,23 @@ +use zbus::{dbus_proxy, Connection, Result}; + +#[dbus_proxy( + interface = "org.openEuler.sysMaster1", + default_service = "org.openEuler.sysMaster", + default_path = "/org/openEuler/sysMaster" +)] +trait sysMaster { + async fn start(&self, name: &str) -> Result<()>; + async fn stop(&self, name: &str) -> Result<()>; +} + +// Although we use `async-std` here, you can use any async runtime of choice. +#[tokio::main] +async fn main() -> Result<()> { + let connection = Connection::session().await?; + + let proxy = sysMasterProxy::new(&connection).await?; + let reply = proxy.start("Maria").await?; + println!("{:?}", reply); + + Ok(()) +} diff --git a/ng/src/bins/sysmaster.rs b/ng/src/bins/sysmaster.rs new file mode 100644 index 00000000..c81a3ee2 --- /dev/null +++ b/ng/src/bins/sysmaster.rs @@ -0,0 +1,21 @@ +use std::error::Error; +use sysmaster_ng::manager::{bus::Bus, MANAGER}; +use zbus::ConnectionBuilder; + +// Although we use `tokio` here, you can use any async runtime of choice. +#[tokio::main] +async fn main() -> Result<(), Box> { + // struct and bus initializes. + let bus: Bus = Bus { count: 0 }; + let _connection = ConnectionBuilder::session()? + .name("org.openEuler.sysMaster")? + .serve_at("/org/openEuler/sysMaster", bus)? + .build() + .await?; + + let manager = MANAGER.lock().await; + manager.start_loop().await; + // let manager = MANAGER.lock().await; + // manager.start_loop().await; + Ok(()) +} diff --git a/ng/src/jobs/mod.rs b/ng/src/jobs/mod.rs new file mode 100644 index 00000000..0ab9bd51 --- /dev/null +++ b/ng/src/jobs/mod.rs @@ -0,0 +1,17 @@ +use once_cell::sync::Lazy; +use std::collections::VecDeque; +use tokio::sync::Mutex; + +#[derive(Clone, Copy)] +pub struct Job { + _id: u32, +} + +impl Job { + pub fn new(_id: u32) -> Job { + Job { _id } + } +} + +pub type Jobs = Vec; +pub static _JOBS: Lazy>> = Lazy::new(|| Mutex::new(VecDeque::new())); diff --git a/ng/src/lib.rs b/ng/src/lib.rs new file mode 100644 index 00000000..81fcb0d4 --- /dev/null +++ b/ng/src/lib.rs @@ -0,0 +1,3 @@ +pub mod jobs; +pub mod manager; +pub mod units; diff --git a/ng/src/manager/bus.rs b/ng/src/manager/bus.rs new file mode 100644 index 00000000..e44ea21e --- /dev/null +++ b/ng/src/manager/bus.rs @@ -0,0 +1,46 @@ +// use std::error::Error; +use zbus::dbus_interface; + +use crate::units::{self, UNITS}; + +pub struct Bus { + pub count: u64, +} + +#[dbus_interface(name = "org.openEuler.sysMaster1")] +impl Bus { + async fn start(&self, name: &str) { + // + println!("start {:?}", name); + let mut units = UNITS.lock().await; + let n = Box::leak(Box::new(name.to_string())); + let u = Box::leak(Box::new(units::Unit::new(name))); + units.insert(n, u); + println!("{:?}", units.contains_key(name)); + if let Some(unit) = units.get(name) { + unit.start(); + units.remove(name); + if units.is_empty() { + println!("units is empty"); + } + } + + // manager.units().await.lock().await.contains(name); + } + + fn stop(&self) { + println!("stop"); + } + + fn reload(&self) { + println!("reload"); + } + + fn restart(&self) { + println!("restart"); + } + + fn daemon_reload(&self) { + println!("daemon_reload"); + } +} diff --git a/ng/src/manager/config.rs b/ng/src/manager/config.rs new file mode 100644 index 00000000..39343ea0 --- /dev/null +++ b/ng/src/manager/config.rs @@ -0,0 +1,12 @@ +use std::io::Error; + +pub(crate) struct Config(i32); +impl Config { + pub fn new() -> Self { + Self(0) + } + + pub async fn load(&self) -> Result<(), Error> { + Ok(()) + } +} diff --git a/ng/src/manager/mod.rs b/ng/src/manager/mod.rs new file mode 100644 index 00000000..43da26ef --- /dev/null +++ b/ng/src/manager/mod.rs @@ -0,0 +1,50 @@ +pub mod bus; +pub mod config; + +use self::config::Config; +use crate::{jobs::Jobs, units::Units}; +use once_cell::sync::Lazy; +use std::{future::pending, io::Error, sync::Arc}; +use tokio::sync::Mutex; + +pub struct Manager { + config: Config, + units: Arc>, + jobs: Arc>, +} + +impl Manager { + pub fn new() -> Self { + Self { + config: Config::new(), + units: Arc::new(Mutex::new(Vec::new())), + jobs: Arc::new(Mutex::new(Vec::new())), + } + } + + pub async fn units(&self) -> Arc> { + self.units.clone() + } + + pub async fn jobs(&self) -> Arc> { + self.jobs.clone() + } + pub async fn load(&mut self) -> Result<(), Error> { + self.config.load().await?; + println!("load config ok"); + Ok(()) + } + + pub async fn start_loop(&self) { + pending::<()>().await; + } +} + +unsafe impl Sync for Manager {} +unsafe impl Send for Manager {} + +pub static MANAGER: Lazy> = Lazy::new(manager_init); + +fn manager_init() -> Mutex { + Mutex::new(Manager::new()) +} diff --git a/ng/src/units/mod.rs b/ng/src/units/mod.rs new file mode 100644 index 00000000..c1b5b5af --- /dev/null +++ b/ng/src/units/mod.rs @@ -0,0 +1,107 @@ +use async_trait::async_trait; +use once_cell::sync::Lazy; +use std::collections::HashMap; +use std::hash::Hash; +use std::path::Path; +use std::str::FromStr; +use tokio::sync::Mutex; + +mod service; +mod socket; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum UnitType { + Service, + Socket, +} + +impl FromStr for UnitType { + type Err = (); + + fn from_str(s: &str) -> Result { + match s { + "service" => Ok(UnitType::Service), + "ssocket" => Ok(UnitType::Socket), + _ => Err(()), + } + } +} + +pub enum _State { + Started, + Stopped, + Loaded, +} + +pub type Units = Vec; +pub static UNITS: Lazy>> = Lazy::new(|| Mutex::new(HashMap::new())); + +pub struct Unit { + id: String, + inner: Box, +} + +impl PartialEq for Unit { + fn eq(&self, other: &Unit) -> bool { + let se: u64 = unsafe { std::mem::transmute(self) }; + let ot: u64 = unsafe { std::mem::transmute(other) }; + se == ot + } +} + +impl Eq for Unit {} + +impl Unit { + pub fn new(name: &str) -> Self { + if let Some(ext) = Path::new(name).extension() { + let ext = ext.to_str().unwrap(); + + Self { + id: name.to_string(), + inner: match ext { + "socket" => Box::new(socket::Socket::new()), + _ => Box::new(service::Service::new()), + }, + } + } else { + log::warn!("No extension found, use default service"); + Self { + id: name.to_string(), + inner: Box::new(service::Service::new()), + } + } + } +} + +impl Unit { + pub fn start(&self) -> bool { + self.inner.start(); + println!("started {}", self.id); + true + } + + fn _stop(&self) -> bool { + self.inner.stop(); + true + } + + fn _load(&self) -> bool { + true + } +} + +#[async_trait] +pub trait UnitTrait { + fn start(&self) -> bool; + fn stop(&self) -> bool; + fn load(&self) -> bool; + fn kind(&self) -> UnitType; +} + +impl PartialEq for dyn UnitTrait { + fn eq(&self, other: &dyn UnitTrait) -> bool { + self.kind() == other.kind() + } +} + +impl Eq for dyn UnitTrait {} diff --git a/ng/src/units/service.rs b/ng/src/units/service.rs new file mode 100644 index 00000000..614ba258 --- /dev/null +++ b/ng/src/units/service.rs @@ -0,0 +1,64 @@ +use tokio::sync::mpsc::{channel, Receiver, Sender}; + +use super::{UnitTrait, UnitType}; + +enum _State { + _Running, + _Stopped, +} + +impl _State { + fn _is_running(&self) -> bool { + match self { + _State::_Running => true, + _State::_Stopped => false, + } + } +} + +struct Config { + _service: ServiceConfig, +} + +struct ServiceConfig { + _first_config: i32, +} + +pub struct Service { + _state: (Sender<_State>, Receiver<_State>), + _config: Config, +} + +impl Service { + pub fn new() -> Self { + Self { + _state: channel::<_State>(1), + _config: Config { + _service: ServiceConfig { _first_config: 0 }, + }, + } + } + + async fn _set_state(&mut self, state: _State) { + self._state.0.send(state).await.unwrap(); + } +} + +impl UnitTrait for Service { + fn start(&self) -> bool { + println!("Service::start"); + true + } + + fn stop(&self) -> bool { + todo!() + } + + fn load(&self) -> bool { + todo!() + } + + fn kind(&self) -> UnitType { + UnitType::Service + } +} diff --git a/ng/src/units/socket.rs b/ng/src/units/socket.rs new file mode 100644 index 00000000..bf8b4b6a --- /dev/null +++ b/ng/src/units/socket.rs @@ -0,0 +1,27 @@ +use super::{UnitTrait, UnitType}; + +#[derive(Debug, Clone, Copy, PartialEq, Default)] +pub struct Socket(i32); +impl Socket { + pub fn new() -> Self { + todo!() + } +} + +impl UnitTrait for Socket { + fn start(&self) -> bool { + todo!() + } + + fn stop(&self) -> bool { + todo!() + } + + fn load(&self) -> bool { + todo!() + } + + fn kind(&self) -> UnitType { + UnitType::Socket + } +} -- Gitee From 2b26b6f988b9f1d3e685ac99f2f3fdd828d50067 Mon Sep 17 00:00:00 2001 From: overweight Date: Mon, 11 Dec 2023 17:36:39 +0800 Subject: [PATCH 2/2] feature: add manager config --- core/sysmaster/src/manager/pre_install.rs | 2 +- docs/design/rfcs/0001-systemd_parser.md | 88 +++--- libs/unit_parser/src/config.rs | 9 +- libs/unit_parser/src/error.rs | 34 +-- libs/unit_parser/src/template.rs | 4 +- ng/Cargo.lock | 335 +++++++++++++++++++++- ng/Cargo.toml | 1 + ng/src/bins/sysmaster.rs | 3 +- ng/src/manager/config.rs | 45 ++- ng/src/manager/mod.rs | 31 +- 10 files changed, 452 insertions(+), 100 deletions(-) diff --git a/core/sysmaster/src/manager/pre_install.rs b/core/sysmaster/src/manager/pre_install.rs index 18cadb90..ad0f17d7 100644 --- a/core/sysmaster/src/manager/pre_install.rs +++ b/core/sysmaster/src/manager/pre_install.rs @@ -549,7 +549,7 @@ impl Install { } let configer = match UeConfigData::load_config(paths, &unit_install.name()) { - Err(unit_parser::error::Error::LoadTemplateError { name: _ }) => { + Err(unit_parser::error::Error::LoadTemplateError { path: _ }) => { return Err(Error::LoadError { msg: format!( "can't load a template unit directly: {}", diff --git a/docs/design/rfcs/0001-systemd_parser.md b/docs/design/rfcs/0001-systemd_parser.md index bfe90520..71c0fca3 100644 --- a/docs/design/rfcs/0001-systemd_parser.md +++ b/docs/design/rfcs/0001-systemd_parser.md @@ -1,13 +1,12 @@ -# systemd单元文件配置解析 - +# systemd 单元文件配置解析 ## 背景 -systemd的单元文件采用ini风格的配置文件,为实现完全兼容ini风格配置文件,sysmaster采用自研的`unit_parser`配置解析库。 +systemd 的单元文件采用 ini 风格的配置文件,为实现完全兼容 ini 风格配置文件,sysmaster 采用自研的`unit_parser`配置解析库。 -## unit_parser的基础定义 +## unit_parser 的基础定义 -在unit_parser配置解析库中,我们将一个完整的unit配置文件称为`Unit`,一个Unit由多个`Section`组成,每个Section有包含多个`Entry`,例如: +在 unit_parser 配置解析库中,我们将一个完整的 unit 配置文件称为`Unit`,一个 Unit 由多个`Section`组成,每个 Section 有包含多个`Entry`,例如: ```ini # ./test.service @@ -24,13 +23,13 @@ RemainAfterExit=yes WantedBy=multi-user.target ``` -该配置文件整体被称为Unit,`Unit`,`Service`,`Install`为Section。`Description`,`Before`为`Unit` Section的两个Entry;`Type`,`ExecStart`,`RemainAfterExit`为`Service` Section的三个Entry;`WantedBy`为`Install` Section的一个Entry。 +该配置文件整体被称为 Unit,`Unit`,`Service`,`Install`为 Section。`Description`,`Before`为`Unit` Section 的两个 Entry;`Type`,`ExecStart`,`RemainAfterExit`为`Service` Section 的三个 Entry;`WantedBy`为`Install` Section 的一个 Entry。 -通常,配置文件至少包含一个Section,而一个Section至少包含一个Entry。 +通常,配置文件至少包含一个 Section,而一个 Section 至少包含一个 Entry。 -## unit_parser提供的功能 +## unit_parser 提供的功能 -unit_parser能够根据用户提供的配置文件,解析得到一个Unit结构体。基础的使用方法如下: +unit_parser 能够根据用户提供的配置文件,解析得到一个 Unit 结构体。基础的使用方法如下: ```rs use std::path::PathBuf; @@ -77,46 +76,46 @@ fn main() { } ``` -这里我们首先定义了`SysmasterUnit`结构体,这个结构体包含三个成员`Unit: SectionUnit`,`Service: SectionService`,`Install: SectionInstall`分别对应配置文件中的`Unit`,`Service`,`Install`三个Section。SectionUnit的每个成员分别对应`Unit` Section中的`Description`,`Before`,类似的,SectionService,SectionInstall与`Service`,`Install` Section中的Entry对应。 +这里我们首先定义了`SysmasterUnit`结构体,这个结构体包含三个成员`Unit: SectionUnit`,`Service: SectionService`,`Install: SectionInstall`分别对应配置文件中的`Unit`,`Service`,`Install`三个 Section。SectionUnit 的每个成员分别对应`Unit` Section 中的`Description`,`Before`,类似的,SectionService,SectionInstall 与`Service`,`Install` Section 中的 Entry 对应。 -在main函数中,我们用config_path_vec构造解析地址,然后使用`SysmasterUnit::load_config`根据config_path_vec生成sysmaster_unit实体。 +在 main 函数中,我们用 config_path_vec 构造解析地址,然后使用`SysmasterUnit::load_config`根据 config_path_vec 生成 sysmaster_unit 实体。 -最后我们尝试打印一下Service Section的Type Entry,如果一切ok,那么终端将打印出“Type is: oneshot”。 +最后我们尝试打印一下 Service Section 的 Type Entry,如果一切 ok,那么终端将打印出“Type is: oneshot”。 在上面的最简示例中,我们存在以下四处特殊用法: -1. `load_config`:根据用户指定的配置文件,解析得到Unit实体。 -2. `#[derive(UnitConfig)]`:声明当前定义的结构体为Unit,并为Unit实现相应的初始化、解析函数。 -3. `#[derive(UnitSection)]`:声明顶前定义的结构体为Section,并为Section实现相应的初始化、解析函数。 -4. `#[entry()]`:为各个Entry配置属性。 +1. `load_config`:根据用户指定的配置文件,解析得到 Unit 实体。 +2. `#[derive(UnitConfig)]`:声明当前定义的结构体为 Unit,并为 Unit 实现相应的初始化、解析函数。 +3. `#[derive(UnitSection)]`:声明顶前定义的结构体为 Section,并为 Section 实现相应的初始化、解析函数。 +4. `#[entry()]`:为各个 Entry 配置属性。 下面我们对这几点内容做具体介绍。 ## 外部接口:load_config -`UnitConfig::load_config()`是unit_parser对外提供的唯一解析函数,第一个参数为解析文件路径数组、第二个参数为Unit完整名称。 +`UnitConfig::load_config()`是 unit_parser 对外提供的唯一解析函数,第一个参数为解析文件路径数组、第二个参数为 Unit 完整名称。 -* 解析文件路径数组:一个Unit实体可以通过不同的配置文件解析得到,因此这里将配置文件路径按照数组的形式组合。对于相同的Entry,在数组后面出现的配置文件具有更高优先级。 -* Unit完整名称:某些Entry的解析依赖于Unit完整名称,因此用户必须传入完整的Unit名称。 +- 解析文件路径数组:一个 Unit 实体可以通过不同的配置文件解析得到,因此这里将配置文件路径按照数组的形式组合。对于相同的 Entry,在数组后面出现的配置文件具有更高优先级。 +- Unit 完整名称:某些 Entry 的解析依赖于 Unit 完整名称,因此用户必须传入完整的 Unit 名称。 ## 过程宏:UnitConfig、UnitSection -UnitConfig、UnitSection是unit_parser定义的两个过程宏,两者的实现比较相似,我们首先介绍UnitConfig。 +UnitConfig、UnitSection 是 unit_parser 定义的两个过程宏,两者的实现比较相似,我们首先介绍 UnitConfig。 -UnitConfig自动为结构体实现UnitConfig trait,该trait主要包括四个函数: +UnitConfig 自动为结构体实现 UnitConfig trait,该 trait 主要包括四个函数: 1. **load_config:** 对外提供的配置解析接口。 -2. **__load:** load_config的内部具体实现。 -1. **__load_default:** 负责解析结构体的初始化,加载缺省值。 -2. **__parse_unit:** 根据用户给定的配置文件,解析得到Unit实体。 +2. **\_\_load:** load_config 的内部具体实现。 +3. **\_\_load_default:** 负责解析结构体的初始化,加载缺省值。 +4. **\_\_parse_unit:** 根据用户给定的配置文件,解析得到 Unit 实体。 -用户调用`UnitConfig::load_config()`,通过给定配置文件路径、Unit名称,解析得到Unit实体。 +用户调用`UnitConfig::load_config()`,通过给定配置文件路径、Unit 名称,解析得到 Unit 实体。 `load_config()`首先调用`__load_default()`加载缺省值,然后调用`__load()`加载用户的配置文件,`__load()`的加载过程会调用`__parse_unit()`。 ## `#[entry()]` -unit_parser允许通过配置属性的方式为不同的Entry采用不同的解析策略。例如: +unit_parser 允许通过配置属性的方式为不同的 Entry 采用不同的解析策略。例如: ```rs pub struct SectionService { @@ -125,18 +124,18 @@ pub struct SectionService { } ``` -这里的意思是:RemainAfterExit的缺省值为`true`。如果用户的配置文件中没有配置RemainAfterExit,那么最终的Unit实体中,RemainAfterExit的值为`true`。 +这里的意思是:RemainAfterExit 的缺省值为`true`。如果用户的配置文件中没有配置 RemainAfterExit,那么最终的 Unit 实体中,RemainAfterExit 的值为`true`。 `#[entry()]`支持配置的属性如下: -* default: Entry的缺省值,如果不配置该属性,Entry的类型必须为Option<> -* append:Entry采用追加模式更新。允许该Entry配置多次,后配置的值将追加到之前解析的值上。类型为Vec<> -* prser:使用用户自定义的解析函数。 -* key:Entry的别名。例如为RemainAfterExit配置`#[entry(key = "RemainWhenExit")]`,在配置文件中解析到`RemainWhenExit`时按照`RemainAfterExit`处理。 +- default: Entry 的缺省值,如果不配置该属性,Entry 的类型必须为 Option<> +- append:Entry 采用追加模式更新。允许该 Entry 配置多次,后配置的值将追加到之前解析的值上。类型为 Vec<> +- prser:使用用户自定义的解析函数。 +- key:Entry 的别名。例如为 RemainAfterExit 配置`#[entry(key = "RemainWhenExit")]`,在配置文件中解析到`RemainWhenExit`时按照`RemainAfterExit`处理。 ### 过程宏:UnitEntry -在前面的示例中,我们的每个Entry都是一些rust基础的数据类型,unit_parser为这些基础数据类型实现了UnitEntry trait。用户自定义的数据类型,需要手动实现UnitEntry trait,或者使用`parser`属性。 +在前面的示例中,我们的每个 Entry 都是一些 rust 基础的数据类型,unit_parser 为这些基础数据类型实现了 UnitEntry trait。用户自定义的数据类型,需要手动实现 UnitEntry trait,或者使用`parser`属性。 ```rs pub trait UnitEntry: Sized { @@ -145,26 +144,25 @@ pub trait UnitEntry: Sized { } ``` -已经实现UnitEntry的数据类型包括: +已经实现 UnitEntry 的数据类型包括: -* ​`bool`​​​:根据systemd.syntax的定义,`yes`​​​,`1`​​​,`on`​​​,`true`解析为`true`​;​`no`​​​,`0`​​​,`off`​​​,`false`​​​ 解析为`false`​​​。 -* ​`chrono::Duration`​​​:根据systemd.time的定义解析。 -* ​`Enum`​​:自定义的枚举类型,可以使用 `#[derive(UnitEntry)]`​​ 自动实现 `UnitEntry`​​。 +- ​`bool`​​​:根据 systemd.syntax 的定义,`yes`​​​,`1`​​​,`on`​​​,`true`解析为`true`​;​`no`​​​,`0`​​​,`off`​​​,`false`​​​ 解析为`false`​​​。 +- ​`chrono::Duration`​​​:根据 systemd.time 的定义解析。 +- ​`Enum`​​:自定义的枚举类型,可以使用 `#[derive(UnitEntry)]`​​ 自动实现 `UnitEntry`​​。 -## nom解析器 +## nom 解析器 ### 预处理 -首先,通过编写PEG语法文件和使用`pest`​​库进行预解析,首先验证 Unit配置文件的基本结构是否合法。 - -解析后的内部状态被包装为`UnitParser`​​和`SectionParser`​​,其求值是惰性的,也不会产生额外的复制开销。`UnitParser`​​是一个返回`SectionParser`​​的迭代器,`SectionParser`​​是一个返回`(String, String)`​​键值对的迭代器。 +首先,通过编写 PEG 语法文件和使用`pest`​​ 库进行预解析,首先验证 Unit 配置文件的基本结构是否合法。 +解析后的内部状态被包装为`UnitParser`​​ 和`SectionParser`​​,其求值是惰性的,也不会产生额外的复制开销。`UnitParser`​​ 是一个返回`SectionParser`​​ 的迭代器,`SectionParser`​​ 是一个返回`(String, String)`​​ 键值对的迭代器。 ## 参考文档 -* [freedesktop.org - systemd.unit](https://www.freedesktop.org/software/systemd/man/systemd.unit.html "systemd.unit") -* [freedesktop.org - systemd.syntax](https://www.freedesktop.org/software/systemd/man/systemd.syntax.html# "systemd.syntax") -* [freedesktop.org - systemd.time](https://www.freedesktop.org/software/systemd/man/systemd.time.html# "systemd.time") -* [freedesktop.org - Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys "Desktop Entry Specification") +- [freedesktop.org - systemd.unit](https://www.freedesktop.org/software/systemd/man/systemd.unit.html "systemd.unit") +- [freedesktop.org - systemd.syntax](https://www.freedesktop.org/software/systemd/man/systemd.syntax.html# "systemd.syntax") +- [freedesktop.org - systemd.time](https://www.freedesktop.org/software/systemd/man/systemd.time.html# "systemd.time") +- [freedesktop.org - Desktop Entry Specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys "Desktop Entry Specification") -  ‍ +‍ diff --git a/libs/unit_parser/src/config.rs b/libs/unit_parser/src/config.rs index 17aa4659..e7be46d7 100644 --- a/libs/unit_parser/src/config.rs +++ b/libs/unit_parser/src/config.rs @@ -37,13 +37,10 @@ pub trait UnitConfig: Sized + Default { /// A convenient function that opens the file that needs to be loaded. fn __load>(path: S, unit_name: &str, res: &mut Self) -> Result<()> { let path = path.as_ref(); - let mut file = File::open(path).context(ReadFileSnafu { - path: path.to_string_lossy().to_string(), - })?; + let mut file = File::open(path).context(ReadFileSnafu { path })?; let mut content = String::new(); - file.read_to_string(&mut content).context(ReadFileSnafu { - path: path.to_string_lossy().to_string(), - })?; + file.read_to_string(&mut content) + .context(ReadFileSnafu { path })?; let parser = crate::parser::UnitParser::new(content.as_ref(), (unit_name,)); Self::__parse_unit(parser, res) } diff --git a/libs/unit_parser/src/error.rs b/libs/unit_parser/src/error.rs index c7b898c4..91a7eb1a 100644 --- a/libs/unit_parser/src/error.rs +++ b/libs/unit_parser/src/error.rs @@ -1,6 +1,6 @@ //! Definitions for all possible errors used in this crate. use snafu::Snafu; -use std::io; +use std::{io, path::PathBuf}; // TODO: change errors to `log::warn`s to prevent one bad file from stalling the entire loading process /// Errors used in crate. @@ -8,29 +8,29 @@ use std::io; #[allow(missing_docs)] #[snafu(visibility(pub))] pub enum Error { - #[snafu(display("{} is not a valid directory.", path))] - InvalidDirectoryError { path: String }, + #[snafu(display("{} is not a valid directory.", path.display()))] + InvalidDirectoryError { path: PathBuf }, - #[snafu(display("Failed to read directory {}: {}.", path, source))] - ReadDirectoryError { source: io::Error, path: String }, + #[snafu(display("Failed to read directory {}: {}.", path.display(), source))] + ReadDirectoryError { source: io::Error, path: PathBuf }, - #[snafu(display("Cannot load a template unit: {}.", name))] - LoadTemplateError { name: String }, + #[snafu(display("Cannot load a template unit: {}.", path.display()))] + LoadTemplateError { path: PathBuf }, - #[snafu(display("{} is not a file.", path))] - NotAFileError { path: String }, + #[snafu(display("{} is not a file.", path.display()))] + NotAFileError { path: PathBuf }, - #[snafu(display("Failed to read file {}: {}.", path, source))] - ReadFileError { source: io::Error, path: String }, + #[snafu(display("Failed to read file {}: {}.", path.display(), source))] + ReadFileError { source: io::Error, path: PathBuf }, #[snafu(display("Failed to read directory entry: {}.", source))] ReadEntryError { source: io::Error }, - #[snafu(display("Unable to read filename for {}.", path))] - FilenameUnreadable { path: String }, + #[snafu(display("Unable to read filename for {}.", path.display()))] + FilenameUnreadable { path: PathBuf }, - #[snafu(display("Invalid filename {}.", filename))] - InvalidFilenameError { filename: String }, + #[snafu(display("Invalid filename {}.", path.display()))] + InvalidFilenameError { path: PathBuf }, #[snafu(display("Unit file should provide at least one section."))] NoSectionError, @@ -47,8 +47,8 @@ pub enum Error { #[snafu(display("Failed to parse {} as the value of entry with key {}.", value, key))] ValueParsingError { key: String, value: String }, - #[snafu(display("Failed to find unit {}.", name))] - NoUnitFoundError { name: String }, + #[snafu(display("Failed to find unit {}.", path.display()))] + NoUnitFoundError { path: PathBuf }, #[snafu(display("Invalid specifier: {}", specifier))] InvalidSpecifierError { specifier: char }, diff --git a/libs/unit_parser/src/template.rs b/libs/unit_parser/src/template.rs index e2273961..23f885c8 100644 --- a/libs/unit_parser/src/template.rs +++ b/libs/unit_parser/src/template.rs @@ -1,4 +1,6 @@ //! Functions and interfaces for systemd unit template related stuff. +use std::path::Path; + use crate::{config::Result, error::Error}; /// Describes the type of a unit file. @@ -22,7 +24,7 @@ pub(crate) fn unit_type(filename: &str) -> Result { let (instance, suffix) = match instance_suffix.split_once('.') { None => { return Err(Error::InvalidFilenameError { - filename: filename.to_string(), + path: Path::new(filename).to_path_buf(), }) } Some(v) => (v.0, v.1), diff --git a/ng/Cargo.lock b/ng/Cargo.lock index 911da2de..5fdae39b 100644 --- a/ng/Cargo.lock +++ b/ng/Cargo.lock @@ -26,6 +26,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "async-broadcast" version = "0.5.1" @@ -235,6 +250,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "byteorder" version = "1.5.0" @@ -262,6 +283,42 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.48.5", +] + +[[package]] +name = "chrono-tz" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c39203181991a7dd4343b8005bd804e7a9a37afb8ac070e43771e8c820bbde" +dependencies = [ + "chrono", + "chrono-tz-build", + "phf", +] + +[[package]] +name = "chrono-tz-build" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f509c3a87b33437b05e2458750a0700e5bdd6956176773e6c7d6dd15a283a0c" +dependencies = [ + "parse-zoneinfo", + "phf", + "phf_codegen", +] + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -271,6 +328,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" version = "0.2.11" @@ -320,6 +383,12 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "enumflags2" version = "0.7.8" @@ -494,6 +563,12 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.3.3" @@ -506,6 +581,29 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "instant" version = "0.1.12" @@ -526,6 +624,21 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.150" @@ -560,6 +673,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "macros" +version = "0.5.1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "memchr" version = "2.5.0" @@ -575,6 +697,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -595,6 +723,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + [[package]] name = "nix" version = "0.26.4" @@ -607,6 +746,25 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -642,6 +800,15 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "os-release" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f29ae2f71b53ec19cc23385f8e4f3d90975195aa3d09171ba3bef7159bec27" +dependencies = [ + "lazy_static", +] + [[package]] name = "parking" version = "2.2.0" @@ -671,6 +838,54 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "parse-zoneinfo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +dependencies = [ + "regex", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", + "uncased", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -905,6 +1120,12 @@ dependencies = [ "libc", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -920,6 +1141,28 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +[[package]] +name = "snafu" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" +dependencies = [ + "doc-comment", + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "socket2" version = "0.4.10" @@ -976,6 +1219,7 @@ dependencies = [ "log", "once_cell", "tokio", + "unit_parser", "zbus", ] @@ -1099,12 +1343,36 @@ dependencies = [ "winapi", ] +[[package]] +name = "uncased" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unit_parser" +version = "0.1.0" +dependencies = [ + "chrono", + "chrono-tz", + "log", + "macros", + "nix 0.24.3", + "nom", + "once_cell", + "os-release", + "snafu", +] + [[package]] name = "version_check" version = "0.9.4" @@ -1123,6 +1391,60 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" + [[package]] name = "winapi" version = "0.3.9" @@ -1145,6 +1467,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -1283,7 +1614,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" dependencies = [ - "nix", + "nix 0.26.4", "winapi", ] @@ -1305,7 +1636,7 @@ dependencies = [ "futures-sink", "futures-util", "hex", - "nix", + "nix 0.26.4", "once_cell", "ordered-stream", "rand", diff --git a/ng/Cargo.toml b/ng/Cargo.toml index a320b7d6..2e7911af 100644 --- a/ng/Cargo.toml +++ b/ng/Cargo.toml @@ -18,3 +18,4 @@ log = "0.4.20" once_cell = "1.19.0" tokio = { version = "1.35.0", features = ["full"] } zbus = { version = "3.14.1", default-features = false, features = ["tokio"] } +unit_parser = { path = "../libs/unit_parser" } diff --git a/ng/src/bins/sysmaster.rs b/ng/src/bins/sysmaster.rs index c81a3ee2..2e4c7375 100644 --- a/ng/src/bins/sysmaster.rs +++ b/ng/src/bins/sysmaster.rs @@ -13,7 +13,8 @@ async fn main() -> Result<(), Box> { .build() .await?; - let manager = MANAGER.lock().await; + let mut manager = MANAGER.lock().await; + manager.load().await?; manager.start_loop().await; // let manager = MANAGER.lock().await; // manager.start_loop().await; diff --git a/ng/src/manager/config.rs b/ng/src/manager/config.rs index 39343ea0..dca792c9 100644 --- a/ng/src/manager/config.rs +++ b/ng/src/manager/config.rs @@ -1,12 +1,39 @@ -use std::io::Error; +// Copyright (c) 2022 Huawei Technologies Co.,Ltd. All rights reserved. +// +// sysMaster is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. +// +#![allow(non_snake_case)] +use unit_parser::prelude::*; -pub(crate) struct Config(i32); -impl Config { - pub fn new() -> Self { - Self(0) - } +#[derive(UnitConfig, Debug, Default)] +pub struct ManagerConfig { + pub Manager: Config, +} + +#[derive(UnitSection, Default, Debug)] +pub struct Config { + #[entry(default = 90)] + pub DefaultRestartSec: u64, + #[entry(default = 90)] + pub DefaultTimeoutSec: u64, + + #[entry(default = "info".to_string())] + pub LogLevel: String, + #[entry(default = "syslog".to_string())] + pub LogTarget: String, + #[entry(default = 10240)] + pub LogFileSize: u32, + #[entry(default = 10)] + pub LogFileNumber: u32, - pub async fn load(&self) -> Result<(), Error> { - Ok(()) - } + #[entry(default = 1048576)] // RELI_HISTORY_MAPSIZE_DEFAULT + pub DbSize: usize, } diff --git a/ng/src/manager/mod.rs b/ng/src/manager/mod.rs index 43da26ef..85b460ac 100644 --- a/ng/src/manager/mod.rs +++ b/ng/src/manager/mod.rs @@ -1,37 +1,32 @@ pub mod bus; pub mod config; -use self::config::Config; -use crate::{jobs::Jobs, units::Units}; +use self::config::ManagerConfig; use once_cell::sync::Lazy; -use std::{future::pending, io::Error, sync::Arc}; +use std::{future::pending, io::Error}; use tokio::sync::Mutex; +use unit_parser::prelude::UnitConfig; pub struct Manager { - config: Config, - units: Arc>, - jobs: Arc>, + config: ManagerConfig, } impl Manager { pub fn new() -> Self { Self { - config: Config::new(), - units: Arc::new(Mutex::new(Vec::new())), - jobs: Arc::new(Mutex::new(Vec::new())), + config: ManagerConfig::default(), } } - pub async fn units(&self) -> Arc> { - self.units.clone() - } - - pub async fn jobs(&self) -> Arc> { - self.jobs.clone() - } + pub const SYSTEM_CONFIG_FILE: &str = "/etc/sysmaster/system.conf"; pub async fn load(&mut self) -> Result<(), Error> { - self.config.load().await?; - println!("load config ok"); + let paths = vec![Manager::SYSTEM_CONFIG_FILE]; + if let Ok(cfg) = ManagerConfig::load_config(paths, "system.conf") { + println!("load config ok {:?}", cfg); + + self.config = cfg; + }; + println!("load config ok {:?}", self.config); Ok(()) } -- Gitee