You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Local live deployment keeps running after SIGTERM and can be deployed twice #681
When the lean process running a local (non-detached) lean live deploy is terminated, the LEAN container stops too, as it does on Ctrl+C. Starting a second local live deployment of a project whose deployment is still running is refused, or at least warned about.
Actual Behavior
DockerManager.run_image registers a handler for SIGINT only (lean/components/docker/docker_manager.py:242), and the container always runs detached. On SIGTERM or SIGHUP (closed SSH session, systemctl stop, timeout, a cancelled CI job or k8s pod) the CLI exits with 143 and the container keeps trading. Reproduced with Docker 29 on Linux.
lean live deploy does not look for a running container of the same project. Containers get a random lean_cli_<uuid> name, so a restart (for example a systemd unit with Restart=always, or simply running the command again after the above) starts a second algorithm on the same brokerage account.
Potential Solution
Route SIGTERM and SIGHUP (where available) through the existing signal_handler, so they stop the container like Ctrl+C.
Label LEAN containers with the project path or id, the environment and the brokerage (labels in run_options).
In live deploy, look up running containers with the same project label and refuse with a clear message, offering lean live stop <project> or a --force flag.
Step 1 is small and I can open it as a PR first. Steps 2 and 3 change the deploy flow, so I'd like to confirm the approach before writing them.
Reproducing the Problem
lean live deploy MyProject --brokerage "Paper Trading" ... &
kill -TERM $!
docker ps --filter name=lean_cli_ # the container is still running
lean live deploy MyProject --brokerage "Paper Trading" ... # a second container starts
System Information
lean-cli master at b4d724c, Python 3.12, Linux, Docker 29.
Checklist
I have completely filled out this template
I have confirmed that this issue exists on the current master branch
I have confirmed that this is not a duplicate issue by searching issues
Yes, opened it now as #712 (step 1 only). Thanks for checking. Steps 2 and 3 still need a decision on the approach from the maintainers, so I left them out.
Activity
pcbeingused333 commentedon Nov 10, 2026
Are you still planning to open step 1? There is a tested patch ready if you would rather have it sent; happy to leave it to you.
Amadeus-22 commentedon Nov 10, 2026
Yes, opened it now as #712 (step 1 only). Thanks for checking. Steps 2 and 3 still need a decision on the approach from the maintainers, so I left them out.