Configuration
Configure the ExecModule inconfig.yaml:
config.yaml
The ExecModule is disabled by default. You must explicitly enable it in your configuration.
Configuration Options
Glob patterns for files to watch. Supports standard glob syntax:
**for recursive directory matching*for wildcard matching{ts,js}for multiple extensions
Shell commands to execute in order. Each command runs in a new shell process.Commands execute sequentially. If a command fails, the pipeline stops.
File Watching
The module watches files matching your glob patterns and automatically restarts the command pipeline when changes are detected.Watched Events
The module responds to these file system events:- File creation
- File modification (content changes)
- File rename
- File deletion
Example Patterns
Command Execution
Commands execute in a sequential pipeline. Each command must complete successfully before the next one starts.Pipeline Behavior
config.yaml
- Runs
npm run build - Waits for build to complete
- If build succeeds, runs
npm start - If build fails, pipeline stops
Long-Running Processes
The last command in the pipeline typically runs indefinitely (like a dev server):- The running process is terminated gracefully (SIGTERM)
- If it doesn’t exit within 3 seconds, it’s force-killed (SIGKILL)
- The entire pipeline restarts from the beginning
Platform Support
Linux/macOS
Commands execute viash -c:
Windows
Commands execute viacmd /C:
Process Management
Process Groups
The module creates process groups to ensure all child processes are properly terminated:- Linux/macOS: Uses
setsid()to create new session IDs - Windows: Uses
CREATE_NEW_PROCESS_GROUPflag
npm start spawning node) are cleaned up when the parent is terminated.
Graceful Shutdown
On file changes or module shutdown:- SIGTERM sent to process group (polite request)
- 3-second grace period for cleanup
- SIGKILL if process doesn’t exit (force kill)
- Reap zombie processes to prevent resource leaks
Use Cases
Development Server with Auto-Rebuild
config.yaml
Test Runner
config.yaml
Multi-Step Build Pipeline
config.yaml
Config File Watcher
config.yaml
Advanced Configuration
Watching Without Execution
If you don’t providewatch, commands run once at startup with no file watching:
Complex Glob Patterns
Troubleshooting
Process Not Terminating
If your process doesn’t handle SIGTERM, it will be force-killed after 3 seconds. To handle graceful shutdown:Too Many Restarts
If your build process generates files that trigger watches:Pipeline Stops After First Command
Commands run sequentially. If the first command fails, the pipeline stops:Performance Considerations
Watch Pattern Optimization
Debouncing
The module processes up to 100 file events in the internal channel. Rapid changes are naturally debounced by the restart process.Limitations
- No interactive commands - Commands requiring user input are not supported
- Sequential execution - Commands cannot run in parallel
- No retry logic - Failed commands stop the pipeline
- No output capture - Command output goes directly to stdout/stderr
Comparison with Other Tools
| Feature | ExecModule | nodemon | chokidar-cli |
|---|---|---|---|
| Built-in | Yes | No | No |
| Config | YAML | CLI/JSON | CLI |
| Pipeline | Sequential | Single command | Single command |
| Process groups | Yes | Partial | No |
| Platform | Cross-platform | Cross-platform | Cross-platform |
Best Practices
- Watch source files only - Don’t watch generated output
- Use specific patterns - Avoid watching unnecessary files
- Handle SIGTERM - Implement graceful shutdown in your processes
- Keep pipelines short - Long pipelines slow down iteration
- Use for development - This module is designed for dev workflows, not production