// SPDX-License-Identifier: CPAL-1.0 // Copyright (c) 2026 Marek Novák. Exhibit A notice: LICENSE at the repository root. //! TEST ONLY: drives the Linux backend with real systemd for tests/linux (the container test). //! It skips the signature check on purpose, so it is an example, never part of a release. //! //! deploy #![allow(clippy::unwrap_used, clippy::expect_used)] use std::time::Duration; use legatus_linux::{HttpHealth, Layout, LinuxBackend, Outcome, Plan, Systemctl}; fn main() { let a: Vec = std::env::args().skip(1).collect(); let [root, app, version, unit, health, archive] = a.as_slice() else { eprintln!("usage: deploy "); std::process::exit(2); }; let bytes = std::fs::read(archive).expect("the archive"); let sha = legatus_protocol::sha256_hex(&bytes); let backend = LinuxBackend::new(Layout::new(root), Systemctl, HttpHealth); let plan = Plan { app, version, unit, health_url: (health != "-").then_some(health.as_str()), health_timeout: Duration::from_secs(15), keep: 3, }; match backend.deploy(&plan, &bytes[..], &sha) { Ok(Outcome::Succeeded { previous }) => { println!( "succeeded previous={}", previous.unwrap_or_else(|| "-".into()) ) } Ok(Outcome::RolledBack { to, healthy, reason, }) => { println!("rolled_back to={to} healthy={healthy} reason={reason}") } Ok(Outcome::Failed { reason }) => println!("failed reason={reason}"), Err(e) => println!("error {e}"), } }