Skip to content

hyp daemon stop on an installed daemon reports "stopped" but launchd immediately relaunches it #644

Description

@bgmcmullen

What happened

➜ hyp daemon stop
daemon: stopped
➜ hyp status
  daemon:   installed, loaded, running, state=healthy, pid=30100, mode=foreground

Both outputs are technically truthful, but together they are extremely misleading: the daemon in hyp status is a new process that launchd relaunched moments after the stop.

Why

  • The installed LaunchAgent is rendered with KeepAlive true by default (src/core/daemon/macos.js). This is deliberate per LLP 0017: the staged-restart design for config replacement requires the service manager to relaunch the daemon on exit (KeepAlive / Restart=always on Linux).
  • hyp daemon stop (runDaemonStop in src/core/commands/daemon.js calling requestDaemonStop in src/core/daemon/runtime.js) never talks to the service manager. It reads the PID file, sends SIGTERM, waits for the process to die, and prints daemon: stopped.
  • launchd sees its KeepAlive'd process exit and restarts it within moments. Net effect: on an installed daemon, hyp daemon stop is a restart with misleading output.

The same applies on Linux (Restart=always in the systemd user unit).

Expected

Either the daemon stays stopped, or the command tells the user it will not. runDaemonStop never checks whether a persistent service is installed, so it cannot do either today.

Possible fixes

  1. When a service is installed, have hyp daemon stop stop it through the service manager (launchctl bootout gui/<uid>/<label> / systemctl --user stop) so the process stays down, and say what a later hyp daemon start will do.
  2. At minimum, detect the installed service and print a warning: the daemon is KeepAlive-managed and will be relaunched; suggest hyp daemon uninstall or the bootout command for a durable stop.

Whichever way this lands, the interaction with LLP 0017's relaunch-on-exit requirement (staged restart for config replacement) needs to stay intact, so option 1 must stop supervision rather than fight it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions