* Stop a running daemon from another CLI process.
()
| 167 | * Stop a running daemon from another CLI process. |
| 168 | */ |
| 169 | async function handleDaemonStop(): Promise<void> { |
| 170 | const result = queryDaemonStatus() |
| 171 | |
| 172 | if (result.status === 'stopped') { |
| 173 | console.log('daemon is not running') |
| 174 | return |
| 175 | } |
| 176 | |
| 177 | if (result.status === 'stale') { |
| 178 | console.log('daemon was stale (cleaned up)') |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | console.log(`stopping daemon (PID: ${result.state!.pid})...`) |
| 183 | const stopped = await stopDaemonByPid() |
| 184 | |
| 185 | if (stopped) { |
| 186 | console.log('daemon stopped') |
| 187 | } else { |
| 188 | console.log('daemon could not be stopped (may have already exited)') |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Parse supervisor arguments from CLI. |
no test coverage detected