Crates.io | pid1 |
lib.rs | pid1 |
version | 0.1.1 |
source | src |
created_at | 2023-10-03 13:14:16.332141 |
updated_at | 2023-10-04 03:02:18.526751 |
description | pid1 handling library for proper signal and zombie reaping of the PID1 process |
homepage | https://github.com/fpco/pid1-rs |
repository | https://github.com/fpco/pid1-rs |
max_upload_size | |
id | 991033 |
size | 18,377 |
pid1 handling library for proper signal and zombie reaping of the PID1 process.
This repository consists of two packages:
pid1
.This library is used to simplify Rust deployment in a containerized environment. Instead of using binaries like Haskell's pid1 or tini in your container, you can use this crate directly.
You must ensure that the launch
method is the first statement in
your main
function:
use std::time::Duration;
use pid1::Pid1Settings;
fn main() {
Pid1Settings::new()
.enable_log(true)
.timeout(Duration::from_secs(2))
.launch()
.expect("Launch failed");
println!("Hello world");
// Rest of the logic...
}
You can also see various example usages here. This function is meant only for Unix systems and the above code is a no-op in Windows.
You can download the pid1
binary that is part of the releases
and use it in your container directly. Example:
FROM alpine:3.14.2
ADD https://github.com/fpco/pid1-rs/releases/download/v0.1.0/pid1-x86_64-unknown-linux-musl /usr/bin/pid1
RUN chmod +x /usr/bin/pid1
ENTRYPOINT [ "pid1" ]
The testing steps are documented in Development.md. We only have some part of it integrated in CI.