Skip to main content

watch

Enable file watching for a process.

Usage​

runix watch <id|name> [flags]

Description​

Watches file paths for changes and automatically restarts the process when changes are detected. Uses fsnotify with configurable debounce to batch rapid file changes.

Examples​

# Watch the process's cwd (default)
runix watch api

# Watch specific paths
runix watch api --paths ./src --paths ./config

# Custom ignore patterns
runix watch api --ignore "*.test.go" --ignore "_test.go"

# Custom debounce duration
runix watch api --debounce 500ms

Flags​

FlagDefaultDescription
--pathsprocess cwdPaths to watch (can specify multiple)
--ignore(see defaults)Glob patterns to ignore
--debounce100msDebounce window for coalescing changes

Default Ignore Patterns​

When no --ignore flags are provided:

.git
node_modules
__pycache__
*.pyc
.DS_Store
vendor
dist
build
bin

How It Works​

  1. An fsnotify watcher is created for each path (recursively)
  2. File change events are collected during the debounce window
  3. After the debounce window, the handler is called with all changed paths
  4. The handler restarts the process
runix watch api
# [Runix] Watching [./src] for process "api" (Ctrl+C to stop)
# [Runix] File changed: ./src/handler.go
# [Runix] Process "api" restarted

The command blocks until interrupted with Ctrl+C.

Config-Based Watch​

Watch can also be configured in runix.yaml:

processes:
api:
entrypoint: ./cmd/api
watch:
paths: ["./src", "./templates"]
ignore: ["*_test.go", "*.md"]
debounce: 200ms

When using runix start api with watch config, the watcher starts automatically.

What's Next​