luigi311 / JellyPlex-Watched

Sync watched between jellyfin and plex locally
GNU General Public License v3.0
366 stars 19 forks source link

Add tini for sigterm handling #128

Closed janw closed 7 months ago

janw commented 7 months ago

This adds tini as a minimal init to ensure that signalling (SIGTERM in particular) is handled properly in containerized environments. Specifically this will ensure a timely shutdown, for example when running docker stop … or restarting the container.

Thank you for making this project! 🙏

luigi311 commented 7 months ago

Interesting, ive never seen this but looking at the github page it looks like it is built into docker natively via the --init flag, is there still a reason to include this into the docker image? The project itself also looks pretty dead, is it still being supported?

janw commented 7 months ago

Other container engines do not provide the init flag unfortunately, for example containerd. Personally, I'm running the service in a Kubernetes cluster, and that does not provide it either.

In that way, adding tini to the container ensures that it is compatible with the wider OCI ecosystem.

If you prefer to not add more dependencies, thankfully jellyplex is simple enough that the same result can be achieved by implementing a very simple signal handler in the application itself; something like:

import signal
import sys

signal.signal(signal.SIGTERM, lambda *_: sys.exit(0))

I'd be happy to adjust the PR if you want.