mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 06:01:34 +02:00
Make terminology more consistent and avoid some "kill child" usages
This commit is contained in:
parent
12d130c3f1
commit
1b5bdee08e
@ -23,8 +23,8 @@ Example use cases:
|
|||||||
* By default, uses `.gitignore` and `.ignore` to determine which files to ignore notifications for
|
* By default, uses `.gitignore` and `.ignore` to determine which files to ignore notifications for
|
||||||
* Support for watching files with a specific extension
|
* Support for watching files with a specific extension
|
||||||
* Support for filtering/ignoring events based on [glob patterns](https://docs.rs/globset/*/globset/#syntax)
|
* Support for filtering/ignoring events based on [glob patterns](https://docs.rs/globset/*/globset/#syntax)
|
||||||
* Launches child processes in a new process group
|
* Launches the command in a new process group
|
||||||
* Sets the following environment variables in the child process:
|
* Sets the following environment variables in the process:
|
||||||
* If a single file changed (depending on the event type):
|
* If a single file changed (depending on the event type):
|
||||||
* `$WATCHEXEC_CREATED_PATH`, the path of the file that was created
|
* `$WATCHEXEC_CREATED_PATH`, the path of the file that was created
|
||||||
* `$WATCHEXEC_REMOVED_PATH`, the path of the file that was removed
|
* `$WATCHEXEC_REMOVED_PATH`, the path of the file that was removed
|
||||||
@ -61,11 +61,11 @@ Call/restart `python server.py` when any Python file in the current directory (a
|
|||||||
|
|
||||||
$ watchexec -e py -r python server.py
|
$ watchexec -e py -r python server.py
|
||||||
|
|
||||||
Call/restart `my_server` when any file in the current directory (and all subdirectories) changes, sending `SIGKILL` to stop the child process:
|
Call/restart `my_server` when any file in the current directory (and all subdirectories) changes, sending `SIGKILL` to stop the command:
|
||||||
|
|
||||||
$ watchexec -r -s SIGKILL my_server
|
$ watchexec -r -s SIGKILL my_server
|
||||||
|
|
||||||
Send a SIGHUP to the child process upon changes (Note: using `-n` here we're executing `my_server` directly, instead of wrapping it in a shell:
|
Send a SIGHUP to the command upon changes (Note: using `-n` here we're executing `my_server` directly, instead of wrapping it in a shell:
|
||||||
|
|
||||||
$ watchexec -n -s SIGHUP my_server
|
$ watchexec -n -s SIGHUP my_server
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ args=(
|
|||||||
'--shell=[Change the wrapping shell, or `none` to disable]'
|
'--shell=[Change the wrapping shell, or `none` to disable]'
|
||||||
'--no-shell[Deprecated, use --shell=none]'
|
'--no-shell[Deprecated, use --shell=none]'
|
||||||
'-n[Shorthand for --shell=none]'
|
'-n[Shorthand for --shell=none]'
|
||||||
'--no-environment[Do not set WATCHEXEC_*_PATH environment variables for child process]'
|
'--no-environment[Do not set WATCHEXEC_*_PATH environment variables for command]'
|
||||||
'--no-meta[Ignore metadata changes]'
|
'--no-meta[Ignore metadata changes]'
|
||||||
'(-p --postpone)'{-p,--postpone}'[Wait until first change to execute command]'
|
'(-p --postpone)'{-p,--postpone}'[Wait until first change to execute command]'
|
||||||
'(-r --restart)'{-r,--restart}'[Restart the process if it''s still running]'
|
'(-r --restart)'{-r,--restart}'[Restart the process if it''s still running]'
|
||||||
|
@ -23,7 +23,7 @@ Comma-separated list of file extensions to filter by. Leading dots (.rs) are all
|
|||||||
Ignores modifications from paths that do not match <pattern>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger <command>.
|
Ignores modifications from paths that do not match <pattern>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger <command>.
|
||||||
|
|
||||||
* `-s`, `--signal`:
|
* `-s`, `--signal`:
|
||||||
Sends the specified signal (e.g. `SIGKILL`) to the child process. Defaults to `SIGTERM`.
|
Sends the specified signal (e.g. `SIGKILL`) to the command. Defaults to `SIGTERM`.
|
||||||
|
|
||||||
* `--shell` <shell>:
|
* `--shell` <shell>:
|
||||||
Change the shell used to run the command. Set to `none` to run the command directly without a shell.
|
Change the shell used to run the command. Set to `none` to run the command directly without a shell.
|
||||||
@ -42,7 +42,7 @@ Shorthand for `--shell=none`.
|
|||||||
Ignore metadata changes.
|
Ignore metadata changes.
|
||||||
|
|
||||||
* `--no-environment`:
|
* `--no-environment`:
|
||||||
Do not set WATCHEXEC_*_PATH environment variables for child process.
|
Do not set WATCHEXEC_*_PATH environment variables for the command.
|
||||||
|
|
||||||
* `-i`, `--ignore` <pattern>:
|
* `-i`, `--ignore` <pattern>:
|
||||||
Ignores modifications from paths that match <pattern>. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.
|
Ignores modifications from paths that match <pattern>. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.
|
||||||
@ -51,7 +51,10 @@ Ignores modifications from paths that match <pattern>. This option can be specif
|
|||||||
Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes <command> to be executed.
|
Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes <command> to be executed.
|
||||||
|
|
||||||
* `-r`, `--restart`:
|
* `-r`, `--restart`:
|
||||||
Terminates the child process group if it is still running when subsequent file modifications are detected. By default, sends `SIGTERM`; use `--signal` to change that.
|
Terminates the command if it is still running when subsequent file modifications are detected. By default, sends `SIGTERM`; use `--signal` to change that.
|
||||||
|
|
||||||
|
* `-W`, `--watch-when-idle`:
|
||||||
|
Ignore events while the process is still running.
|
||||||
|
|
||||||
* `-c`, `--clear`:
|
* `-c`, `--clear`:
|
||||||
Clears the screen before executing <command>.
|
Clears the screen before executing <command>.
|
||||||
|
@ -126,7 +126,7 @@ where
|
|||||||
.help("Ignore metadata changes")
|
.help("Ignore metadata changes")
|
||||||
.long("no-meta"))
|
.long("no-meta"))
|
||||||
.arg(Arg::with_name("no-environment")
|
.arg(Arg::with_name("no-environment")
|
||||||
.help("Do not set WATCHEXEC_*_PATH environment variables for child process")
|
.help("Do not set WATCHEXEC_*_PATH environment variables for the command")
|
||||||
.long("no-environment"))
|
.long("no-environment"))
|
||||||
.arg(Arg::with_name("once").short("1").hidden(true))
|
.arg(Arg::with_name("once").short("1").hidden(true))
|
||||||
.arg(Arg::with_name("watch-when-idle")
|
.arg(Arg::with_name("watch-when-idle")
|
||||||
|
@ -36,10 +36,10 @@ pub struct Config {
|
|||||||
/// Clear the screen before each run.
|
/// Clear the screen before each run.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub clear_screen: bool,
|
pub clear_screen: bool,
|
||||||
/// If Some, send that signal (e.g. SIGHUP) to the child on change.
|
/// If Some, send that signal (e.g. SIGHUP) to the command on change.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub signal: Option<String>,
|
pub signal: Option<String>,
|
||||||
/// If true, kill the child if it's still running when a change comes in.
|
/// If true, kill the command if it's still running when a change comes in.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub restart: bool,
|
pub restart: bool,
|
||||||
/// Interval to debounce the changes. (milliseconds)
|
/// Interval to debounce the changes. (milliseconds)
|
||||||
@ -54,7 +54,7 @@ pub struct Config {
|
|||||||
/// Ignore metadata changes.
|
/// Ignore metadata changes.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub no_meta: bool,
|
pub no_meta: bool,
|
||||||
/// Do not set WATCHEXEC_*_PATH environment variables for child process.
|
/// Do not set WATCHEXEC_*_PATH environment variables for the process.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub no_environment: bool,
|
pub no_environment: bool,
|
||||||
/// Skip auto-loading .gitignore files
|
/// Skip auto-loading .gitignore files
|
||||||
@ -74,6 +74,7 @@ pub struct Config {
|
|||||||
/// Interval for polling. (milliseconds)
|
/// Interval for polling. (milliseconds)
|
||||||
#[builder(default = "1000")]
|
#[builder(default = "1000")]
|
||||||
pub poll_interval: u32,
|
pub poll_interval: u32,
|
||||||
|
/// Ignore events emitted while the command is running.
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
pub watch_when_idle: bool,
|
pub watch_when_idle: bool,
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ impl From<io::Error> for Error {
|
|||||||
Self::Io(match err.raw_os_error() {
|
Self::Io(match err.raw_os_error() {
|
||||||
Some(os_err) => match os_err {
|
Some(os_err) => match os_err {
|
||||||
7 => {
|
7 => {
|
||||||
let msg = "There are so many changed files that the environment variables of the child process have been overrun. Try running with --no-meta or --no-environment.";
|
let msg = "There are so many changed files that the environment variables of the command have been overrun. Try running with --no-meta or --no-environment.";
|
||||||
io::Error::new(io::ErrorKind::Other, msg)
|
io::Error::new(io::ErrorKind::Other, msg)
|
||||||
}
|
}
|
||||||
_ => err,
|
_ => err,
|
||||||
|
@ -157,7 +157,7 @@ mod imp {
|
|||||||
use crate::signal::ConvertToLibc;
|
use crate::signal::ConvertToLibc;
|
||||||
|
|
||||||
let signo = signal.convert_to_libc();
|
let signo = signal.convert_to_libc();
|
||||||
debug!("Sending {:?} (int: {}) to child process", signal, signo);
|
debug!("Sending {:?} (int: {}) to the command", signal, signo);
|
||||||
self.c_signal(signo);
|
self.c_signal(signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ impl ExecHandler {
|
|||||||
clear_screen();
|
clear_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Launching child process");
|
debug!("Launching command");
|
||||||
let mut guard = self.child_process.write()?;
|
let mut guard = self.child_process.write()?;
|
||||||
*guard = Some(process::spawn(
|
*guard = Some(process::spawn(
|
||||||
&self.args.cmd,
|
&self.args.cmd,
|
||||||
@ -219,11 +219,11 @@ impl Handler for ExecHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SIGHUP scenario: --signal was given, but --restart was not
|
// SIGHUP scenario: --signal was given, but --restart was not
|
||||||
// Just send a signal (e.g. SIGHUP) to the child, do nothing more
|
// Just send a signal (e.g. SIGHUP) to the command, do nothing more
|
||||||
(true, false, Some(signal), _) => signal_process(&self.child_process, signal),
|
(true, false, Some(signal), _) => signal_process(&self.child_process, signal),
|
||||||
|
|
||||||
// Custom restart behaviour (--restart was given, and --signal specified):
|
// Custom restart behaviour (--restart was given, and --signal specified):
|
||||||
// Send specified signal to the child, wait for it to exit, then run the command again
|
// Send specified signal to the command, wait for it to exit, then run the command again
|
||||||
(_, true, Some(signal), false) => {
|
(_, true, Some(signal), false) => {
|
||||||
signal_process(&self.child_process, signal);
|
signal_process(&self.child_process, signal);
|
||||||
wait_on_process(&self.child_process);
|
wait_on_process(&self.child_process);
|
||||||
@ -231,7 +231,7 @@ impl Handler for ExecHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default restart behaviour (--restart was given, but --signal wasn't specified):
|
// Default restart behaviour (--restart was given, but --signal wasn't specified):
|
||||||
// Send SIGTERM to the child, wait for it to exit, then run the command again
|
// Send SIGTERM to the command, wait for it to exit, then run the command again
|
||||||
(_, true, None, false) => {
|
(_, true, None, false) => {
|
||||||
signal_process(&self.child_process, Signal::SIGTERM);
|
signal_process(&self.child_process, Signal::SIGTERM);
|
||||||
wait_on_process(&self.child_process);
|
wait_on_process(&self.child_process);
|
||||||
|
Loading…
Reference in New Issue
Block a user