krallin / tini

A tiny but valid `init` for containers
MIT License
9.82k stars 507 forks source link

Add respawn option #146

Open zoxpx opened 4 years ago

zoxpx commented 4 years ago

REASON FOR CHANGE: The tini-based container could be run via non-docker container runtime (e.g. containerd, cri-o or raw runC), which may not support the "xxx --restart always/on-failure" behavior. This change adds the restarts capability straight into the tini code.

yosifkit commented 4 years ago

As just an interested party, I would vote against this addition. tini's strength is its limited scope and this seems outside that. Restarting stopped containers should be done by whatever is orchestrating them.

All Tini does is spawn a single child (Tini is meant to be run in a container), and wait for it to exit all the while reaping zombies and performing signal forwarding.

zoxpx commented 4 years ago

This PR implements the respawn in a minimalistic way, and it is a great solution for container-applications that need to be able to restart internally, without also stopping the container. Note that systemd(1) also supports restarts/respawns, as well as many container-runtimes, but sadly restarts/respawns are not included in the runc spec and container-runtimes are not required to implement it.

amkartashov commented 3 years ago

for those who interested in this functionality, check https://github.com/gorilych/restarter

Habbie commented 2 years ago

With this PR, a SIGTERM send to tini is forwarded to the child process, which terminates, and then gets restarted. I feel SIGTERM to tini should disable respawns, and thus exit tini when the child process exits after that SIGTERM.