containers / ai-lab-recipes

Examples for building and running LLM services and applications locally with Podman
Apache License 2.0
111 stars 110 forks source link

ilab wrapper: `exec` for better signal handling / termination #697

Closed omertuc closed 3 months ago

omertuc commented 3 months ago

If the wrapper script is killed, the container will be left running. Instead of just running the command, use exec to replace the wrapper script with the command, so that the command will receive the same signals as the wrapper script and the container will be terminated as expected.

eranco74 commented 3 months ago

I just checked and it works as expected. I execute ilab model serve from systemd service, prior to this change if I execute systemctl stop ilab.service the ilab container would keep running and the service journal log would say:

 Jul 25 12:46:40 ip-172-31-6-97.ec2.internal systemd[1672]: ilab.service: State 'final-sigterm' timed out. Killing.
Jul 25 12:46:40 ip-172-31-6-97.ec2.internal systemd[1672]: ilab.service: Killing process 75939 (conmon) with signal SIGKILL.
Jul 25 12:46:40 ip-172-31-6-97.ec2.internal systemd[1672]: ilab.service: Failed with result 'timeout'.
Jul 25 12:46:40 ip-172-31-6-97.ec2.internal systemd[1672]: Stopped ilab model serve service.

With this change the systemd service behaves properly.

rhatdan commented 3 months ago

LGTM