fix: prevent gateway double-spawn when process undetected by listProcesses()#293
Open
amit183239 wants to merge 1 commit intocloudflare:mainfrom
Open
fix: prevent gateway double-spawn when process undetected by listProcesses()#293amit183239 wants to merge 1 commit intocloudflare:mainfrom
amit183239 wants to merge 1 commit intocloudflare:mainfrom
Conversation
…esses() Fixes cloudflare#289 Two changes to avoid the "gateway already running / port in use" error that occurs when the container already has a running gateway that findExistingMoltbotProcess() fails to detect: 1. Broaden command matching to also check for `/usr/local/bin/start-openclaw.sh` (full path), so invocations via `bash /usr/local/bin/start-openclaw.sh` are recognised. 2. Add a TCP port pre-check in ensureMoltbotGateway() before spawning. If port 18789 is already listening, the gateway is up regardless of what listProcesses() returned, so we skip the spawn entirely.
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.
Fixes #289
Summary
findExistingMoltbotProcess()matches command strings likestart-openclaw.shandopenclaw gateway, but the sandbox process list may expose the process asbash /usr/local/bin/start-openclaw.sh(full path with shell prefix), which the existing checks missensureMoltbotGateway()spawns a second instance which immediately fails with:gateway already running (pid N); lock timeout after 5000msandPort 18789 is already in useChanges
Broader command matching — also match
/usr/local/bin/start-openclaw.sh(full path) so bash-invoked scripts are detected correctlyTCP port pre-check before spawning — before starting a new process, probe port
18789via TCP. If it's already listening, the gateway is running regardless of whatlistProcesses()returned, so skip the spawn entirely. Acts as a safety net against any future process-detection gaps.