Repository navigation
bug: stop the container when the CLI is terminated, not only on Ctrl+C - #712
Open
Amadeus-22 wants to merge 1 commit into
Open
Amadeus-22 wants to merge 1 commit into
Amadeus-22 wants to merge 1 commit into
Conversation
run_image only handled SIGINT, so a SIGTERM or SIGHUP to a non-detached command (systemctl stop, timeout, a closed SSH session, a cancelled CI job) ended the CLI with 143 and left the LEAN container running. Route both signals through the existing handler. SIGHUP is skipped on Windows, where it does not exist. Part of QuantConnect#681. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #681 (step 1 of the proposed solution)
Description
DockerManager.run_imageregistered its stop handler forSIGINTonly. When a non-detached command such as a locallean live deployreceivedSIGTERMorSIGHUP(systemctl stop,timeout, a closed SSH session, a cancelled CI job or pod), the CLI exited with 143 and the LEAN container kept running, still trading.SIGTERMandSIGHUPnow go through the same handler as Ctrl+C, so the container is stopped and removed the same way.SIGHUPis skipped on Windows, where it does not exist.Steps 2 and 3 of the issue (labelling containers and refusing a second deployment of the same project) change the deploy flow, so they are left out of this PR.
How Has This Been Tested?
test_run_image_stops_the_container_when_the_cli_is_terminatedintests/components/docker/test_docker_manager.py: checks the handler is registered forSIGINT,SIGTERMand (where available)SIGHUP, and thatSIGTERMkills the container. It fails on master and passes with the fix.run_imageon a container runningsleep 600, thenkill -TERMon the CLI:🤖 Generated with Claude Code