#process #init #cli

pid1

pid1 handling library for proper signal and zombie reaping of the PID1 process

2 releases

0.1.1 Oct 4, 2023
0.1.0 Oct 3, 2023

#1876 in Command line utilities

Download history 396/week @ 2023-12-14 221/week @ 2023-12-21 359/week @ 2023-12-28 485/week @ 2024-01-04 357/week @ 2024-01-11 438/week @ 2024-01-18 273/week @ 2024-01-25 260/week @ 2024-02-01 352/week @ 2024-02-08 355/week @ 2024-02-15 543/week @ 2024-02-22 503/week @ 2024-02-29 401/week @ 2024-03-07 354/week @ 2024-03-14 333/week @ 2024-03-21 608/week @ 2024-03-28

1,801 downloads per month
Used in 3 crates (2 directly)

MIT license

12KB
160 lines

pid1-rs

Rust

pid1 handling library for proper signal and zombie reaping of the PID1 process.

This repository consists of two packages:

  • pid1 crate: Library meant to be used by your Rust applications.
  • pid1-exe crate: Binary which internally uses pid1 crate for container deployments. The binary name is pid1.

pid1 Library Usage

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.

Using pid1 binary

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" ]

Development

The testing steps are documented in Development.md. We only have some part of it integrated in CI.

Dependencies

~2.5MB
~56K SLoC