Skip to content

gateway stop kills ALL profile gateways instead of only the current profile #4402

@b988yht6zn-cell

Description

@b988yht6zn-cell

Bug Description

hermes gateway stop (or work gateway stop) kills gateway processes for ALL profiles, not just the current one.

Root Cause

find_gateway_pids() in hermes_cli/gateway.py (line 31) searches ps aux output for generic patterns like:

  • hermes_cli.main gateway
  • hermes gateway
  • gateway/run.py

These patterns match all gateway processes regardless of which HERMES_HOME/profile they belong to. When multiple profiles are running (e.g. default + work), stopping one kills all of them.

Impact

On macOS, the gateway_command() stop handler (line 1915) correctly uses profile-scoped launchctl stop via launchd_stop() with the right label (ai.hermes.gateway vs ai.hermes.gateway-work). However, it then unconditionally calls kill_gateway_processes() on line 1933, which sweeps ALL gateway PIDs without profile filtering.

Environment

  • macOS (launchd)
  • Two profiles running: default (ai.hermes.gateway) and work (ai.hermes.gateway-work)
  • Both share the same ProgramArguments pattern, differing only in HERMES_HOME env var

Suggested Fix

find_gateway_pids() should filter by the current HERMES_HOME — either by:

  1. Checking the process environment variables for the matching HERMES_HOME
  2. Reading the PID file from get_hermes_home() / 'gateway.pid' and only targeting that PID
  3. Comparing the launchd label in the process command line

Option 2 (PID file) is simplest since get_running_pid() from gateway.status already reads the profile-scoped PID file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/cliCLI entry point, hermes_cli/, setup wizardcomp/gatewayGateway runner, session dispatch, deliverytype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions