Closed who closed 7 years ago
Thank you for the report. The current behavior is indeed intentional, but I agree that it would be nice to have an option (--force
? --interrupt
?) with the described behavior.
The child process would probably have to be run in the background and inotifywait
would then trigger the termination & re-execution of the child process.
I'd certainly be interested in a PR, if you have a concrete idea on how to implement this. Otherwise, I can also take a look.
The trouble with adding options to the existing command is that the trigger
script consumes 1...n
parameters as file names to monitor. If you added an option for --interrupt
, and you also wanted trigger
to monitor a silly file named --interrupt
, there would be a conflict in file/option processing.
I guess it would work to require parameters to come immediately after trigger
:
Good: trigger --interrupt nodejs index.js
Bad: trigger nodejs index.js --interrupt
If you added an option for --interrupt, and you also wanted trigger to monitor a silly file named --interrupt, there would be a conflict in file/option processing.
I think this kind of problem is usually solved by passing --
to separate options from arguments, like so:
trigger nodejs --interrupt -- index.js --silly-file
On the other hand...
I guess it would work to require parameters to come immediately after trigger:
Good: trigger --interrupt nodejs index.js
... I think this would be a very good solution for trigger
:+1:
Resolved in the newest version
If
trigger
watches a file which contains some sort of loop or long-running task, and the watched file changes,trigger
does not re-execute. It would be nice to have an option wheretrigger
would abort all previous executions of a script, even if they are still running, when it detects changes to one or more of the watched files.Here's a repro:
1) Create
index.js
:2) Start watching index.js with a trigger:
3) Execute a
touch
onindex.js
$ touch index.js
4) Note that
trigger
does not re-launchnode index.js