feat(channel): add status and stop commands for service management

- Add `qwen channel status` to check running service info
- Add `qwen channel stop` to gracefully stop the service
- Add PID file tracking to prevent duplicate service instances
- Update documentation with new commands and usage

This enables users to manage the channel service from another terminal
without needing to use Ctrl+C on the foreground process.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-03-26 03:06:48 +00:00
parent 1a605ec973
commit 697898a9fb
6 changed files with 298 additions and 2 deletions

View file

@ -233,9 +233,15 @@ qwen channel start
# Start a single channel
qwen channel start my-channel
# Check if the service is running
qwen channel status
# Stop the running service
qwen channel stop
```
The bot runs in the foreground. Press `Ctrl+C` to stop.
The bot runs in the foreground. Press `Ctrl+C` to stop, or use `qwen channel stop` from another terminal.
### Multi-Channel Mode
@ -243,6 +249,14 @@ When you run `qwen channel start` without a name, all channels defined in `setti
Each channel uses its own `cwd` from its config, so different channels can work on different projects simultaneously.
### Service Management
The channel service uses a PID file (`~/.qwen/channels/service.pid`) to track the running instance:
- **Duplicate prevention**: Running `qwen channel start` while a service is already running will show an error instead of starting a second instance
- **`qwen channel stop`**: Gracefully stops the running service from another terminal
- **`qwen channel status`**: Shows whether the service is running, its uptime, and session counts per channel
### Crash Recovery
If the agent process crashes unexpectedly, the channel service automatically restarts it and attempts to restore all active sessions. Users can continue their conversations without starting over.
@ -250,4 +264,4 @@ If the agent process crashes unexpectedly, the channel service automatically res
- Sessions are persisted to `~/.qwen/channels/sessions.json` while the service is running
- On crash: the agent restarts within 3 seconds and reloads saved sessions
- After 3 consecutive crashes, the service exits with an error
- On clean shutdown (Ctrl+C): session data is cleared — the next start is always fresh
- On clean shutdown (Ctrl+C or `qwen channel stop`): session data is cleared — the next start is always fresh