Skip to content

feat(daemon): add profile-aware daemon naming for multi-gateway support#671

Closed
bjesuiter wants to merge 7 commits intoopenclaw:mainfrom
bjesuiter:feature/daemon-profile-support
Closed

feat(daemon): add profile-aware daemon naming for multi-gateway support#671
bjesuiter wants to merge 7 commits intoopenclaw:mainfrom
bjesuiter:feature/daemon-profile-support

Conversation

@bjesuiter
Copy link
Copy Markdown
Contributor

@bjesuiter bjesuiter commented Jan 10, 2026

Enable running multiple gateway daemons simultaneously by incorporating CLAWDBOT_PROFILE into service names:

  • macOS: `com.clawdbot.` (was: `com.clawdbot.gateway`)
  • Linux: `clawdbot-gateway-`
  • Windows: `Clawdbot Gateway ()`

This allows users to run separate gateways for different configurations (e.g., main bot + rescue bot with redundant gateway) on the same machine without conflicts.

Use Case

Run multiple Clawdbot instances with different profiles AND DIFFERENT GATEWAYS on the same machine, each gateway with its own daemon service that can be independently started/stopped/managed.
Allows to have "recovery" agents on the same machine as your main bot but with reduced config for "failsafe" mode.
I configure this bot with a way cheaper model, like the free ones from opencode zen or the free google antigravity subscription with gemini-3-flash. It's enough to have the bot call the "usage" skill to check limits or restart the main bot.

Note for users

You should use this multi-gateway feature only for redundancy for failure recovery cases!
One gateway can serve different agent configs/profiles already, like work and personal.

Changes the default base path from "/" to "./" so the control UI works
correctly when served under a custom basePath (e.g., /jbclawd/).

Previously, assets were referenced with absolute paths like /assets/...,
which failed when the UI was served under a subpath. With relative paths
(./assets/...), the browser resolves them relative to the HTML location,
making the UI work regardless of the configured basePath.
…bjesuiter/clawdbot into ui-build-default-to-relative-path
Enable running multiple gateway daemons simultaneously by incorporating
CLAWDBOT_PROFILE into service names:

- macOS: com.clawdbot.<profile> (was: com.clawdbot.gateway)
- Linux: clawdbot-gateway-<profile>
- Windows: Clawdbot Gateway (<profile>)

This allows users to run separate gateways for different configurations
(e.g., personal + work) on the same machine without conflicts.
@steipete
Copy link
Copy Markdown
Contributor

Should we support this instead of steering people to use one gateway?

we support multi-agent and multi-provider?

@steipete steipete added the question Further information is requested label Jan 10, 2026
@steipete
Copy link
Copy Markdown
Contributor

@joshp123 also sth where i am curious about your opt

@bjesuiter
Copy link
Copy Markdown
Contributor Author

@steipete Yes, I'd like to support that! I'm running two gateways on my Mac mini, so that I have two distinct bots, one normal bot and a rescue bot.

Comes in very handy if I or my main agent messes up it's own config and the gateway does not start up anymore.
Also useful when updates crash something.

@steipete
Copy link
Copy Markdown
Contributor

ahhhhhh FAIR

@steipete
Copy link
Copy Markdown
Contributor

I wasa thinking of emergency commands that spin up a claude but this is better. Use the --dev skill with C-3PO for a fun cos-play agent!!

Change daemon service methods (isLoaded, stop, restart) to accept
profile?: string instead of env: Record<string, string | undefined>.

This makes the API cleaner and more explicit - callers now pass just
the profile value rather than the entire env object. Internal functions
extract env.CLAWDBOT_PROFILE at the call site.
Cover resolveGatewayLaunchAgentLabel, resolveGatewaySystemdServiceName,
and resolveGatewayWindowsTaskName with tests for default profile, custom
profiles, edge cases (empty, whitespace, case-insensitive 'default').
@bjesuiter bjesuiter marked this pull request as ready for review January 10, 2026 22:43
@bjesuiter
Copy link
Copy Markdown
Contributor Author

@steipete I reviewed this pr in tandem with opencode. Note that i can't test it with linux or windows right now.

Please check if you like the signature change on the service interface (if there is any from your perspective).
In one version i had

service.restart({env: process.env})

and I wanted to make it explicit what is passed, so i explicitely pass profile?: string now.

Should be ready to merge otherwise! :)

Examples running on macos

First run of bun clawdbot --profile jbphoenix daemon status

$ tsx src/entry.ts --profile jbphoenix daemon status

🦞 ClawdBot 2026.1.8-2 (8db5018) — I'm not saying your workflow is chaotic... I'm just bringing a linter and a helmet.

│
◑  Checking gateway status....gateway connect failed: Error: unauthorized
◇
Service: LaunchAgent (loaded)
File logs: /tmp/clawdbot/clawdbot-2026-01-10.log
Command: /Users/bjesuiter/.bun/bin/bun /Users/bjesuiter/Develop/clawdbot/src/entry.ts --profile jbphoenix gateway --port 18800
Service file: /Users/bjesuiter/Library/LaunchAgents/com.clawdbot.jbphoenix.plist
Daemon env: CLAWDBOT_PROFILE=jbphoenix

Service config looks out of date or non-standard.
Service config issue: Gateway service PATH missing required dirs: /opt/homebrew/bin
Service config issue: Gateway service uses Bun; Bun is incompatible with WhatsApp + Telegram providers. (/Users/bjesuiter/.bun/bin/bun)
Recommendation: run "clawdbot doctor" (or "clawdbot doctor --repair").
Config (cli): /Users/bjesuiter/.clawdbot-jbphoenix/clawdbot.json
Config (daemon): /Users/bjesuiter/.clawdbot-jbphoenix/clawdbot.json

Gateway: bind=loopback (127.0.0.1), port=18800 (service args)
Probe target: ws://127.0.0.1:18800
Dashboard: http://127.0.0.1:18800/jbphoenix/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: running (pid 78548, state active)
Warm-up: launch agents can take a few seconds. Try again shortly.
RPC probe: failed
RPC target: ws://127.0.0.1:18800
  gateway closed (1008): unauthorized
  Gateway target: ws://127.0.0.1:18800
  Source: cli --url
  Config: /Users/bjesuiter/.clawdbot-jbphoenix/clawdbot.json

Port 18800 is already in use.
- pid 78548 bjesuiter: /Users/bjesuiter/.bun/bin/bun /Users/bjesuiter/Develop/clawdbot/src/entry.ts --profile jbphoenix gateway --port 18800 (127.0.0.1:18800)
- Gateway already running locally. Stop it (clawdbot daemon stop) or use a different port.
Listening: 127.0.0.1:18800
Other gateway-like services detected (best effort):
- com.bjesuiter.launchctl-setenv (user, plist: /Users/bjesuiter/Library/LaunchAgents/com.bjesuiter.launchctl-setenv.plist)
- com.clawdbot.jbclawd (user, plist: /Users/bjesuiter/Library/LaunchAgents/com.clawdbot.jbclawd.plist)
- com.clawdbot.jbphoenix (user, plist: /Users/bjesuiter/Library/LaunchAgents/com.clawdbot.jbphoenix.plist)
Cleanup hint: launchctl bootout gui/$UID/com.clawdbot.gateway
Cleanup hint: rm ~/Library/LaunchAgents/com.clawdbot.gateway.plist

Recommendation: run a single gateway per machine. One gateway supports multiple agents.
If you need multiple gateways, isolate ports + config/state (see docs: /gateway#multiple-gateways-same-host).

Troubles: run clawdbot status
Troubleshooting: https://docs.clawd.bot/troubleshooting

Uninstalling my old non standard daemon

❯ bun clawdbot --profile jbphoenix daemon uninstall
$ tsx src/entry.ts --profile jbphoenix daemon uninstall

🦞 ClawdBot 2026.1.8-2 (8db5018) — WhatsApp Business, but without the business.

Moved LaunchAgent to Trash: /Users/bjesuiter/.Trash/com.clawdbot.jbphoenix.plist

Installing the new, standard daemon

 bun clawdbot --profile jbphoenix daemon install
$ tsx src/entry.ts --profile jbphoenix daemon install

🦞 ClawdBot 2026.1.8-2 (8db5018) — If something's on fire, I can't extinguish it—but I can write a beautiful postmortem.

Installed LaunchAgent: /Users/bjesuiter/Library/LaunchAgents/com.clawdbot.jbphoenix.plist
Logs: /Users/bjesuiter/.clawdbot-jbphoenix/logs/gateway.log

My new launch plist (would be working, if i had the right auth setup for my dev instance of clawdbot :D)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.clawdbot.jbphoenix</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/bjesuiter/.local/share/fnm/node-versions/v24.12.0/installation/bin/node</string>
      <string>/Users/bjesuiter/Develop/contributions/clawdbot/dist/index.js</string>
      <string>gateway</string>
      <string>--port</string>
      <string>18800</string>
    </array>
    
    <key>StandardOutPath</key>
    <string>/Users/bjesuiter/.clawdbot-jbphoenix/logs/gateway.log</string>
    <key>StandardErrorPath</key>
    <string>/Users/bjesuiter/.clawdbot-jbphoenix/logs/gateway.err.log</string>
    <key>EnvironmentVariables</key>
    <dict>
    <key>PATH</key>
    <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
    <key>CLAWDBOT_PROFILE</key>
    <string>jbphoenix</string>
    <key>CLAWDBOT_STATE_DIR</key>
    <string>/Users/bjesuiter/.clawdbot-jbphoenix</string>
    <key>CLAWDBOT_CONFIG_PATH</key>
    <string>/Users/bjesuiter/.clawdbot-jbphoenix/clawdbot.json</string>
    <key>CLAWDBOT_GATEWAY_PORT</key>
    <string>18800</string>
    <key>CLAWDBOT_GATEWAY_TOKEN</key>
    <string>6a306b5d490eabefd0cb98ba43a432338b9b0497e8966dad</string>
    <key>CLAWDBOT_LAUNCHD_LABEL</key>
    <string>com.clawdbot.jbphoenix</string>
    </dict>
  </dict>
</plist>

@bjesuiter
Copy link
Copy Markdown
Contributor Author

this time i merged main properly :D

@bjesuiter
Copy link
Copy Markdown
Contributor Author

this time i merged main properly :D

updates on main are too fast :/ I have to go to bed now, if this thing is still here in the morning, i'll give it to claude for fixing ^^

@thewilloftheshadow
Copy link
Copy Markdown
Member

No need to worry about keeping up with main, we will re-base it when we merge it!

@bjesuiter
Copy link
Copy Markdown
Contributor Author

Created follow-up issue for browser tool port conflict: #898

This tracks the CDP port configuration needed for multi-gateway support.

@bjesuiter
Copy link
Copy Markdown
Contributor Author

@steipete If full multi-gateway support sounds too scary to you, we could also update the config to have dedicated "main gateway" and "recovery gateway".
This would fix my problem and might be easier to control the blast radius, also in response to potentially more support messages when multi-gateway would be allowed.

steipete added a commit that referenced this pull request Jan 15, 2026
Thanks @bjesuiter.

Co-authored-by: Benjamin Jesuiter <bjesuiter@gmail.com>
@steipete steipete closed this Jan 15, 2026
@steipete
Copy link
Copy Markdown
Contributor

Landed on main with squash commit 77cf40d.

  • Profile-aware daemon service naming + profile-only service checks.
  • Launchd label resolution helper + mac bundled-gateway doc note for profile plist.

Tests: pnpm lint (2 warnings: typescript-eslint/restrict-template-expressions in src/infra/outbound/channel-selection.ts and src/gateway/server-methods/agent.ts), pnpm build, pnpm test.

Thanks @bjesuiter!

@bjesuiter bjesuiter deleted the feature/daemon-profile-support branch January 15, 2026 09:30
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Thanks @bjesuiter.

Co-authored-by: Benjamin Jesuiter <bjesuiter@gmail.com>
heatherstew44-maker pushed a commit to heatherstew44-maker/openclaw that referenced this pull request Mar 8, 2026
* fix: run Rust tests in CI

Fixes openclaw#670

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: run Rust tests in CI

Adds a separate test.yml workflow to run existing Rust unit tests.

Fixes openclaw#670

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: use mock TranscriptionManager in CI tests

Swap to a mock adapter during CI to avoid compiling whisper/Vulkan.
The mock has the same interface but no heavy dependencies.
Existing tests don't exercise transcription code, so this is safe.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants