Skip to content

Commit 6e946e0

Browse files
committed
Initial commit
0 parents  commit 6e946e0

File tree

3 files changed

+417
-0
lines changed

3 files changed

+417
-0
lines changed

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 cytopia
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# watcherd
2+
3+
watcherd will look for directory changes (added and deleted directories) under the specified path (`-p`) and will execute specified commands or shell scripts (`-a`, `-d`) depending on the event.
4+
Once all events have happened during one round (`-i`), a trigger command can be executed (`-t`).
5+
Note, the trigger command will only be execute when at least one add or delete command has succeeded with exit code 0.
6+
7+
### Modes
8+
9+
watcherd can either use the native [inotifywait](https://linux.die.net/man/1/inotifywait) implementation or if this is not available on your system use a custom bash implementation. The default is to use bash.
10+
11+
### Examples
12+
13+
Assuming `vhost-add.sh` will add nginx vhost config files and `vhost-del.sh` will remove nginx vhost config files, the following will then be able to create new nginx vhosts on-the-fly, simply by adding or deleting folders in your main www directory. The trigger command will simply force nginx to reload its configuration after directory changes occured.
14+
15+
```shell
16+
watcherd -p /var/www -a vhost-add.sh -d vhost-del.sh -t "nginx -s stop"
17+
```
18+
19+
### Usage
20+
21+
```shell
22+
Usage: watcherd -p <path> -a <cmd> -d <cmd> [-t <cmd> -w <str> -i <int> -v]
23+
watcherd --help
24+
watcherd --version
25+
26+
watcherd will look for directory changes (added and deleted directories) under
27+
the specified path (-p) and will execute specified commands or shell scripts
28+
(-a, -d) depending on the event. Once all events have happened during one round
29+
(-i), a trigger command can be executed (-t). Note, the trigger command will
30+
only be execute when at least one add or delete command has succeeded with exit
31+
code 0.
32+
33+
Required arguments:
34+
-p <path> Path to directoy to watch for changes.
35+
-a <cmd> Command to execute when a directory was added.
36+
The full path of the new dir will be appended as an argument to
37+
this command.
38+
-d <cmd> Command to execute when a directory was deletd.
39+
The full path of the new dir will be appended as an argument to
40+
this command.
41+
42+
Optional arguments:
43+
-t <cmd> Command to execute after all directories have been added or
44+
deleted during one round.
45+
No argument will be appended.
46+
-w <str> The directory watcher to use. Valid values are:
47+
'inotify': Uses inotifywait to watch for directory changes.
48+
'bash': Uses a bash loop to watch for directory changes.
49+
The default is to use 'bash' as the watcher.
50+
-i <int> When using the bash watcher, specify the interval in seconds
51+
for how often to look for directory changes.
52+
-v Verbose output.
53+
54+
Misc arguments:
55+
--help Show this help screen.
56+
--version Show version information.
57+
```

0 commit comments

Comments
 (0)