Stop the daemon.
()
| 1054 | |
| 1055 | @daemon_app.command("stop") |
| 1056 | def daemon_stop() -> None: |
| 1057 | """Stop the daemon.""" |
| 1058 | from ._daemon_paths import daemon_pid_path |
| 1059 | from .client import is_daemon_running, stop_daemon |
| 1060 | |
| 1061 | pid_path = daemon_pid_path() |
| 1062 | if not pid_path.exists() and not is_daemon_running(): |
| 1063 | _typer.echo("Daemon is not running.") |
| 1064 | return |
| 1065 | |
| 1066 | stop_daemon() |
| 1067 | |
| 1068 | # Wait for process to exit (check both pid file and socket) |
| 1069 | import time |
| 1070 | |
| 1071 | deadline = time.monotonic() + 5.0 |
| 1072 | while time.monotonic() < deadline: |
| 1073 | if not pid_path.exists() and not is_daemon_running(): |
| 1074 | break |
| 1075 | time.sleep(0.1) |
| 1076 | |
| 1077 | if pid_path.exists() or is_daemon_running(): |
| 1078 | _typer.echo("Warning: daemon may not have stopped cleanly.", err=True) |
| 1079 | else: |
| 1080 | _typer.echo("Daemon stopped.") |
| 1081 | |
| 1082 | |
| 1083 | @app.command("run-daemon", hidden=True) |
nothing calls this directly
no test coverage detected