diff options
| author | diogo464 <[email protected]> | 2025-06-19 10:03:56 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-06-19 10:03:56 +0100 |
| commit | 5101d9c410a7c901ea20636d2a4e56b3282a1c14 (patch) | |
| tree | 4b229f6ced108f14957a7e80c2c30880f7174811 /README.md | |
| parent | 7b7dbf8948fa063d040a744a4903be1df75ca943 (diff) | |
Add wait subcommand for blocking until process termination
Implements a new 'wait' subcommand that blocks until a specified daemon process terminates, with configurable timeout and polling interval.
Features:
- Default 30-second timeout, configurable with --timeout flag
- Infinite wait with --timeout 0
- Configurable polling interval with --interval flag (default 1 second)
- Quiet operation - only shows errors on failure
- Preserves PID files (doesn't clean up)
- Exit codes: 0 for success, 1 for failure
Usage examples:
- demon wait my-process # Wait 30s
- demon wait my-process --timeout 0 # Wait indefinitely
- demon wait my-process --timeout 60 --interval 2 # Custom timeout/interval
Added comprehensive test suite covering:
- Non-existent processes
- Already terminated processes
- Normal process termination
- Timeout scenarios
- Infinite timeout behavior
- Custom polling intervals
Updated documentation:
- README.md with wait command reference and usage examples
- LLM guide with detailed wait command documentation
- Integration examples for development workflows
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 24 |
1 files changed, 21 insertions, 3 deletions
| @@ -117,6 +117,20 @@ demon cat web-server | |||
| 117 | demon cat web-server --stdout | 117 | demon cat web-server --stdout |
| 118 | ``` | 118 | ``` |
| 119 | 119 | ||
| 120 | ### `demon wait <id> [--timeout <seconds>] [--interval <seconds>]` | ||
| 121 | Wait for a daemon process to terminate. | ||
| 122 | |||
| 123 | ```bash | ||
| 124 | # Wait with default 30-second timeout | ||
| 125 | demon wait web-server | ||
| 126 | |||
| 127 | # Wait indefinitely | ||
| 128 | demon wait web-server --timeout 0 | ||
| 129 | |||
| 130 | # Wait with custom timeout and polling interval | ||
| 131 | demon wait web-server --timeout 60 --interval 2 | ||
| 132 | ``` | ||
| 133 | |||
| 120 | ### `demon clean` | 134 | ### `demon clean` |
| 121 | Remove orphaned files from processes that are no longer running. | 135 | Remove orphaned files from processes that are no longer running. |
| 122 | 136 | ||
| @@ -145,6 +159,9 @@ demon run db-server docker run -p 5432:5432 postgres | |||
| 145 | # Monitor everything | 159 | # Monitor everything |
| 146 | demon list | 160 | demon list |
| 147 | demon tail api-server --stderr # Watch for errors | 161 | demon tail api-server --stderr # Watch for errors |
| 162 | |||
| 163 | # Wait for a specific service to finish | ||
| 164 | demon wait api-server | ||
| 148 | ``` | 165 | ``` |
| 149 | 166 | ||
| 150 | ### LLM Agent Integration | 167 | ### LLM Agent Integration |
| @@ -154,6 +171,9 @@ Designed for seamless automation and LLM agent workflows: | |||
| 154 | # Agents can start long-running processes | 171 | # Agents can start long-running processes |
| 155 | demon run data-processor python process_large_dataset.py | 172 | demon run data-processor python process_large_dataset.py |
| 156 | 173 | ||
| 174 | # Wait for the process to complete | ||
| 175 | demon wait data-processor --timeout 3600 # 1 hour timeout | ||
| 176 | |||
| 157 | # Check status programmatically | 177 | # Check status programmatically |
| 158 | if demon status data-processor | grep -q "RUNNING"; then | 178 | if demon status data-processor | grep -q "RUNNING"; then |
| 159 | echo "Processing is still running" | 179 | echo "Processing is still running" |
| @@ -223,9 +243,7 @@ demon list --quiet | |||
| 223 | demon list --quiet | grep -q "web-server:" || demon run web-server python -m http.server | 243 | demon list --quiet | grep -q "web-server:" || demon run web-server python -m http.server |
| 224 | 244 | ||
| 225 | # Wait for process to finish | 245 | # Wait for process to finish |
| 226 | while demon list --quiet | grep -q "backup-job:.*:RUNNING"; do | 246 | demon wait backup-job --timeout 0 # Wait indefinitely |
| 227 | sleep 5 | ||
| 228 | done | ||
| 229 | 247 | ||
| 230 | # Get all running processes | 248 | # Get all running processes |
| 231 | demon list --quiet | grep ":RUNNING" | cut -d: -f1 | 249 | demon list --quiet | grep ":RUNNING" | cut -d: -f1 |
