krallin/tini

Tini doesn't work in the case of script in entrypoint.sh

TommyLike opened this issue · 3 comments

The content of entrypoint.sh is below:

#!/bin/bash
while :; do echo 'Starting to running @ $(date)'; do something; sleep 21600; done

and I started the tini on ubuntu vm via command:

tini -s -- ./entrypoint.sh

It seems we will have the working process unterminated(parentless process) when kill the tini process.

This might be the issue from bash, since it works if we replace the while statement with exec command.

Maybe I should use crond instead of the while and sleep code?

You might be able to make this work if you add -g to Tini, which will cause it to signal all processes in its process group when you signal Tini itself.

That being said, what you're doing here seems to not really the use case for Tini. Tini's goal is to reap any daemon processes while Tini itself is alive. Tini's goal isn't to kill all your subprocesses when it exits. For this, you could use a PID namespace to force all the processes to exit when PID 1 in the namespace exits (this is what Docker sets up for you).

I'll close the issue for now but feel free to follow up if you still have questions