Skip to content

feat: Multi-user Gateway process isolation and configurable port#345

Open
RyanShu555 wants to merge 1 commit intoValueCell-ai:mainfrom
RyanShu555:main
Open

feat: Multi-user Gateway process isolation and configurable port#345
RyanShu555 wants to merge 1 commit intoValueCell-ai:mainfrom
RyanShu555:main

Conversation

@RyanShu555
Copy link

@RyanShu555 RyanShu555 commented Mar 8, 2026

Summary

This PR implements multi-user process isolation for the OpenClaw Gateway and adds configurable port support, resolving issues where one user's Gateway operations would interfere with another user's Gateway process on Windows multi-user systems.

Features

  • Multi-user process isolation: Each user's Gateway writes its PID to %APPDATA%\clawx\gateway.pid for ownership tracking
    • Prevents User A's Gateway restart from killing User B's Gateway process
    • Detects orphaned processes via WebSocket connection test
    • Shows appropriate error messages when port is occupied by another user
  • Configurable Gateway port: Users can now configure a custom port for the Gateway in Settings
    • Port configuration is persisted across restarts
    • findExistingGateway() correctly uses configured port instead of hardcoded default

Changes

  • electron/gateway/manager.ts:
    • Added PID file management (writePidFile, readPidFile, clearPidFile, getPIdFilePath)
    • Added orphaned process detection (isLikelyOrphanedProcess)
    • Fixed findExistingGateway() to use this.status.port instead of hardcoded PORTS.OPENCLAW_GATEWAY
    • Removed premature clearPidFile() call from startProcess() (was breaking multi-user isolation)
  • src/pages/Settings/index.tsx: Added Gateway port configuration UI
  • src/i18n/locales/*/settings.json: Added translations for port settings

Testing

Tested on Windows with multiple user accounts:

  • ✅ User A and User B can run Gateway independently on different ports
  • ✅ Restart operations don't affect other users' Gateway processes
  • ✅ Port conflicts show appropriate error messages

Merged Upstream Changes

This PR also includes the following upstream changes:

Checklist

  • Code follows project style guidelines
  • Self-reviewed before submitting
  • Tested on target platform (Windows)

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@RyanShu555 RyanShu555 changed the title feat: Multi-user Gateway isolation and configurable port feat: Multi-user Gateway process isolation and configurable port Mar 8, 2026
- Allow users to configure OpenClaw Gateway port via Settings
- Gateway reads configured port on startup from settings
- Add port input field in Settings page (valid range: 1024-65535)
- Add i18n translations (en, zh, ja)
- Default port: 18789

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant