Skip to content

Commit 39a3002

Browse files
croakywarp-agent
andauthored
watch: add file watching with automatic process restart
Add watching to procman where it benefits projects of all languages rather than build it into Ruby or Go projects/frameworks. Syntax: add `# watch: PATTERNS` to Procfile.dev entries: web: bundle exec ruby cmd/web.rb # watch: lib/**/*.rb On file change matching a pattern, procman sends SIGINT to the process, waits for exit, and restarts. Changes are debounced (500ms) to avoid rapid restarts during multi-file saves. Processes without a watch annotation behave exactly as before. #4 Co-authored-by: Warp <agent@warp.dev>
1 parent 5b17301 commit 39a3002

5 files changed

Lines changed: 460 additions & 29 deletions

File tree

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,29 @@ running processes, wait 5s, and then send a `SIGKILL` to all remaining processes
6060
It runs the processes in `Procfile.dev` "as-is";
6161
It does not load environment variables from `.env` before running.
6262

63+
## File watching
64+
65+
Add `# watch: PATTERNS` to automatically restart a process when files change:
66+
67+
```txt
68+
web: bundle exec ruby cmd/web.rb # watch: lib/**/*.rb,ui/**/*.haml
69+
esbuild: bun run buildwatch
70+
```
71+
72+
Patterns are relative to the directory containing `Procfile.dev`.
73+
Glob patterns support `*` (single directory) and `**` (recursive).
74+
Processes without a watch annotation run without file watching.
75+
Changes are debounced (500ms) to avoid rapid restarts.
76+
On change, procman sends SIGINT, waits for the process to exit, then restarts it.
77+
6378
`procman` is distributed via Go source code,
6479
not via a Homebrew package.
6580

66-
`procman` depends on [github.com/creack/pty](https://github.com/creack/pty/tree/master)
67-
for a PTY interface.
81+
`procman` depends on:
82+
83+
- [creack/pty](https://github.com/creack/pty) for PTY interface
84+
- [fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) for file watching
85+
- [bmatcuk/doublestar](https://github.com/bmatcuk/doublestar) for glob patterns
6886

6987
## Developing
7088

go.mod

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ module github.com/croaky/procman
22

33
go 1.25
44

5-
require github.com/creack/pty v1.1.24
5+
require (
6+
github.com/bmatcuk/doublestar/v4 v4.10.0
7+
github.com/creack/pty v1.1.24
8+
github.com/fsnotify/fsnotify v1.9.0
9+
)
10+
11+
require golang.org/x/sys v0.13.0 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs=
2+
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
13
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
24
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
5+
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
6+
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
7+
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
8+
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

0 commit comments

Comments
 (0)