diff --git a/README.md b/README.md index c90abe5..d3a4c8b 100644 --- a/README.md +++ b/README.md @@ -844,6 +844,29 @@ ocp restart openclaw gateway restart ``` +### Env var change (e.g. `CLAUDE_BIND`, `CLAUDE_CODE_OAUTH_TOKEN`) doesn't take effect after restart + +On **macOS**, `ocp restart` does a full `launchctl bootout` + `bootstrap` of the agent, which **re-reads the plist `EnvironmentVariables`** — so an env change you made (in `~/Library/LaunchAgents/dev.ocp.proxy.plist`) actually takes effect: + +```bash +ocp restart +``` + +This is deliberate: the older `launchctl kickstart -k` only re-execs the process and **reuses launchd's cached environment**, so plist env edits would be silently ignored. If you ever restart the agent by hand, use bootout+bootstrap, not `kickstart -k`: + +```bash +launchctl bootout gui/$(id -u)/dev.ocp.proxy 2>/dev/null +launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/dev.ocp.proxy.plist +``` + +Verify the new value reached the running process: + +```bash +ps -E -p "$(launchctl print gui/$(id -u)/dev.ocp.proxy 2>/dev/null | awk '/pid =/{print $3}')" | tr ' ' '\n' | grep CLAUDE_ +``` + +On **Linux**, `systemctl --user restart` already re-reads the unit's `EnvironmentFile`, so no special handling is needed. + ### Usage shows "unknown" Usually caused by an expired Claude CLI session. Fix: diff --git a/ocp b/ocp index dbf4f48..a30e889 100755 --- a/ocp +++ b/ocp @@ -573,21 +573,42 @@ Usage: ocp restart Restart the Claude proxy service ocp restart gateway Restart the OpenClaw gateway (briefly disconnects all Telegram/Discord bots) + +Note (macOS): restart does a full launchctl bootout + bootstrap, NOT +`kickstart -k`. bootout+bootstrap re-reads the plist's EnvironmentVariables, +so an env change you made (e.g. CLAUDE_BIND, CLAUDE_CODE_OAUTH_TOKEN) actually +takes effect. `kickstart -k` only re-execs the process and reuses launchd's +cached env, so env edits would be silently ignored. (Linux systemctl already +re-reads its EnvironmentFile on restart.) EOF } +# macOS only: reload a launchd agent via bootout + bootstrap so plist +# EnvironmentVariables are re-read (kickstart -k would reuse the cached env). +# Args: