diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..4c044d6 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: ['pc-windows-msvc', 'apple-darwin', 'unknown-linux-gnu'] + arch: [x86_64, aarch64] + include: + - runner: ubuntu-latest + os: unknown-linux-gnu + - runner: windows-latest + os: pc-windows-msvc + - runner: macos-latest + os: apple-darwin + runs-on: ${{ matrix.runner }} + + steps: + - uses: actions/checkout@v4 + + - name: Configure runner + run: rustup target add ${{matrix.arch}}-${{matrix.os}} + + - name: Configure runner + if: matrix.os == 'unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get -o Acquire:retries=3 install libsystemd-dev + + - name: Build + shell: pwsh + run: cargo build --target ${{matrix.arch}}-${{matrix.os}} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 6b2b0c6..d969520 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "ceviche" -version = "0.5.2" +version = "0.6.0" edition = "2021" license = "MIT/Apache-2.0" -homepage = "https://github.com/wayk/ceviche-rs" -repository = "https://github.com/wayk/ceviche-rs" +homepage = "https://github.com/devolutions/ceviche-rs" +repository = "https://github.com/devolutions/ceviche-rs" authors = ["Marc-André Moreau ", "Sébastien Duquette ", "Richard Markiewicz "] keywords = ["daemon", "service"] description = "Rust daemon/service wrapper" @@ -23,7 +23,7 @@ winapi = { version = "0.3", features = ["winbase", "winerror", "winuser", "winsv widestring = "0.4.3" [target.'cfg(target_os = "linux")'.dependencies] -systemd-rs = "^0.1.2" +systemd-rs = { version="^0.1.2", optional = true } [target.'cfg(target_os = "macos")'.dependencies] core-foundation = "0.9" diff --git a/examples/foobar/Cargo.toml b/examples/foobar/Cargo.toml index 5cb702f..e9114d5 100644 --- a/examples/foobar/Cargo.toml +++ b/examples/foobar/Cargo.toml @@ -3,8 +3,8 @@ name = "foobar_service" version = "0.1.0" edition = "2021" license = "MIT/Apache-2.0" -homepage = "https://github.com/wayk/ceviche-rs" -repository = "https://github.com/wayk/ceviche-rs" +homepage = "https://github.com/devolutions/ceviche-rs" +repository = "https://github.com/devolutions/ceviche-rs" authors = ["Marc-André Moreau "] keywords = ["daemon", "service"] description = "Rust daemon/service wrapper" diff --git a/src/controller/linux.rs b/src/controller/linux.rs index 0bfdbda..b8f64d9 100644 --- a/src/controller/linux.rs +++ b/src/controller/linux.rs @@ -7,14 +7,18 @@ use std::sync::mpsc; use ctrlc; use log::{debug, info}; -use systemd_rs::login::monitor::{Category, Monitor}; -use systemd_rs::login::session as login_session; use crate::controller::{ControllerInterface, ServiceMainFn}; use crate::session; use crate::Error; use crate::ServiceEvent; +#[cfg(feature = "systemd-rs")] +use { + systemd_rs::login::monitor::{Category, Monitor}, + systemd_rs::login::session as login_session, +}; + type LinuxServiceMainWrapperFn = extern "system" fn(args: Vec); pub type Session = session::Session_; @@ -179,6 +183,7 @@ impl ControllerInterface for LinuxController { } } +#[cfg(feature = "systemd-rs")] fn run_monitor( tx: mpsc::Sender>, ) -> Result { @@ -240,7 +245,11 @@ macro_rules! Service { pub fn dispatch(service_main: ServiceMainFn, args: Vec) { let (tx, rx) = mpsc::channel(); - let _monitor = run_monitor(tx.clone()).expect("Failed to run session monitor"); + #[cfg(feature = "systemd-rs")] + { + let _monitor = run_monitor(tx.clone()).expect("Failed to run session monitor"); + } + let _tx = tx.clone(); ctrlc::set_handler(move || {