fix: pass base_cmd to background commander thread so commands actually run#30
Open
rezasabourinejad wants to merge 1 commit into
Open
fix: pass base_cmd to background commander thread so commands actually run#30rezasabourinejad wants to merge 1 commit into
rezasabourinejad wants to merge 1 commit into
Conversation
…y run
When commander() is called with run_in_background=True (the default), the
background command was never executed. The thread was created as
`threading.Thread(target=cmd_in_back, daemon=True)` without forwarding the
constructed `base_cmd`, so `cmd_in_back(cmd)` was invoked with no arguments
and raised before subprocess.Popen ever ran:
TypeError: cmd_in_back() missing 1 required positional argument: 'cmd'
Forward base_cmd to the thread via args=(base_cmd,).
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.
Summary
When
commander()is called withrun_in_background=True(the default), the background command is never executed. The worker thread is created without forwarding the constructedbase_cmd:So
cmd_in_back()is invoked with no arguments and raises immediately, beforesubprocess.Popenever runs:The thread is a daemon and the exception is only logged, so the calling task/request still appears to "succeed" while having no effect.
Impact
Every background
commander()action silently does nothing, including:Command.apply— the panel "Apply configuration" action; configs are never regenerated and no progress/log is shown in the panel.Command.apply_users— added / removed / disabled users are never written to the live proxy config.Command.restart_services,Command.update,Command.install,Command.get_cert, etc.This has a real security / billing impact for anyone running paid or private nodes:
apply_usersnever removes their UUID from the live sing-box / xray config.So revocation from the panel does not actually cut users off until some
run_in_background=Falsepath (e.g. a manualbash apply_configs.shon the server) happens to regenerate the config.Root cause
Regression introduced in 4adef40 ("fix: zombie process"), which moved the background
subprocess.Popen(base_cmd, ...)into acmd_in_backthread (towait()on and reap the child) but did not forwardbase_cmdto the thread.Fix
Pass
base_cmdto the thread:Testing
Reproduced and verified on a 12.3.x deployment. Before the fix, the background-tasks worker logged the
TypeErroron every panel apply and deleted / expired users remained connected to the live config. After this one-line change, the background command runs: the panel apply executes (progress/log returns) and user revocations take effect.