Repository navigation
Serve the scheduler and flow port only from the gateway process - #56
Merged
Merged
Conversation
OpenClaw loads plugins in every process that touches config: the gateway, but also `openclaw --help`, `openclaw cron list`, plugin discovery, setup. Each of those armed a TriggerScheduler and tried to bind the flow port. A CLI that exits took its timers with it; one that hung (a diagnostic `openclaw --help` left running for 13 days on a customer box) became a second scheduler for the same trigger records and squatted on 18793 with stale code, which the real gateway then silently yielded to. shouldServe() keys on two host signals: api.registrationMode must be "full" (discovery, cli-metadata and setup loads never serve) and the process must be the one started as `openclaw gateway run`. CLAWFLOW_SERVE=1 forces it on for tests and unusual hosts; CLAWFLOW_NO_SERVE keeps its meaning for spawned child agents and operator CLIs and always wins. The decision is logged at register time so a rollout can be verified from the journal.
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.
Problem
OpenClaw loads plugins in every process that touches config. Each load armed a
TriggerSchedulerand tried to bind the flow port. A hungopenclaw --helpon a customer box (13 days old) held port 18793 with stale code and its own scheduler; the real gateway silently skipped its server ("port already in use").Fix
shouldServe(api, argv, env): serve only whenapi.registrationModeis"full"(or absent, older hosts) and argv isopenclaw gateway run(or bareopenclaw gateway).CLAWFLOW_NO_SERVEalways wins;CLAWFLOW_SERVE=1forces on (tests, unusual hosts). The decision is logged at register time:clawflow: registrationMode=… argv=… → serving|not serving.Verified on a 7.1 box: the gateway's plugin-loading process is the compile-cache respawn of
node /usr/bin/openclaw gateway run(same argv);PluginRegistrationModeis"full" | "discovery" | "tool-discovery" | "setup-only" | "setup-runtime" | "cli-metadata"intypes-*.d.ts.Tests
tests/should-serve.test.ts(gateway, help, cron list, discovery, setup, env switches). Full suite 228 passing. Version 1.6.3 → 1.6.4.